summary refs log tree commit diff stats
path: root/.travis.yml
diff options
context:
space:
mode:
authorael-code <tommy.ael@gmail.com>2016-11-09 01:26:06 +0100
committerael-code <tommy.ael@gmail.com>2016-11-25 17:34:57 +0100
commit3c8086ece60c839eaaac868678415a5e85eb13db (patch)
tree52e8df6f4da51f761f9aa0c1b585c95789274712 /.travis.yml
parent601b6f8ff008c1d94351a6300816d898f08531f3 (diff)
downloadranger-3c8086ece60c839eaaac868678415a5e85eb13db.tar.gz
Make use of standard logging library to handle logs
The goal is to provide an easy api to log stuff and a straigthforward way of inspect them. This has been achieved using the standard logging library. The default behaviour is pretty similar to the old one, in the sense that all the the produced logs will be collected in a queue that can be inspected with the curses log viewer (`display_log` command). Moreover the `--logfile` cli option has been added and it can be used to specifya destination file for all the logs in such a way that the same log can be viewed at runtime as well as inspected after a program crash.

The verbosity and the format of the log message is controlled by the already existent `--debug` command line flag:

 - Normal mode:
    A concise log format will be used and only important message will be logged (log level > INFO)

    Example:
    ```
    [INFO] Ranger version 1.7.2
    [INFO] Running on Python 3.5.2 (default, Jun 28 2016, 08:46:01) [GCC 6.1.1 20160602]
    [INFO] Process ID is 1497

    ```

 - Debug mode:
    An extended log format will be used and all the message will be logged.

    Example:
    ```
    23:17:43,719 [ranger.core.main] |INFO| Ranger version 1.7.2
    23:17:43,719 [ranger.core.main] |INFO| Running on Python 3.5.2 (default, Jun 28 2016, 08:46:01) [GCC 6.1.1 20160602]
    23:17:43,719 [ranger.core.main] |INFO| Process ID is 1515
    23:17:43,720 [ranger.core.main] |DEBUG| config dir: '/home/groucho/.config/ranger'
    23:17:43,720 [ranger.core.main] |DEBUG| cache dir: '/home/groucho/.cache/ranger'
    23:17:43,738 [ranger.core.actions] |DEBUG| Sourcing config file '/path/to/ranger/config/rc.conf'
    ```

fixes #713
Diffstat (limited to '.travis.yml')
0 files changed, 0 insertions, 0 deletions
e-height: 125%; } td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>

#include "xmpp/xmpp.h"

#include "ui/ui.h"
#include "ui/stub_ui.h"

#include "config/preferences.h"

#include "command/cmd_defs.h"
#include "command/cmd_funcs.h"
#include "command/cmd_ac.h"

#define CMD_ALIAS "/alias"

void
cmd_alias_add_shows_usage_when_no_args(void** state)
{
    gchar* args[] = { "add", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);
}

void
cmd_alias_add_shows_usage_when_no_value(void** state)
{
    gchar* args[] = { "add", "alias", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);
}

void
cmd_alias_remove_shows_usage_when_no_args(void** state)
{
    gchar* args[] = { "remove", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);
}

void
cmd_alias_show_usage_when_invalid_subcmd(void** state)
{
    gchar* args[] = { "blah", NULL };

    expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS);

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);
}

void
cmd_alias_add_adds_alias(void** state)
{
    gchar* args[] = { "add", "hc", "/help commands", NULL };

    expect_cons_show("Command alias added /hc -> /help commands");

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);

    char* returned_val = prefs_get_alias("hc");
    assert_string_equal("/help commands", returned_val);

    free(returned_val);
}

void
cmd_alias_add_shows_message_when_exists(void** state)
{
    gchar* args[] = { "add", "hc", "/help commands", NULL };

    cmd_init();
    prefs_add_alias("hc", "/help commands");
    cmd_ac_add("/hc");

    expect_cons_show("Command or alias '/hc' already exists.");

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);
}

void
cmd_alias_remove_removes_alias(void** state)
{
    gchar* args[] = { "remove", "hn", NULL };

    prefs_add_alias("hn", "/help navigation");

    expect_cons_show("Command alias removed -> /hn");

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);

    char* returned_val = prefs_get_alias("hn");
    assert_null(returned_val);

    free(returned_val);
}

void
cmd_alias_remove_shows_message_when_no_alias(void** state)
{
    gchar* args[] = { "remove", "hn", NULL };

    expect_cons_show("No such command alias /hn");

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);
}

void
cmd_alias_list_shows_all_aliases(void** state)
{
    gchar* args[] = { "list", NULL };

    prefs_add_alias("vy", "/vercheck on");
    prefs_add_alias("q", "/quit");
    prefs_add_alias("hn", "/help navigation");
    prefs_add_alias("hc", "/help commands");
    prefs_add_alias("vn", "/vercheck off");

    // write a custom checker to check the correct list is passed
    expect_any(cons_show_aliases, aliases);

    gboolean result = cmd_alias(NULL, CMD_ALIAS, args);
    assert_true(result);
}