Skip to content

Commit

Permalink
Add CLI flag for disabling console log printing.
Browse files Browse the repository at this point in the history
- Add CLI flag that will disable the console module from printing:
  Short: -q
  Log:   --disable-console-logs
- Update documentation with new CLI flags

Closes #1912
  • Loading branch information
mgoffin authored and Mike Goffin committed Apr 20, 2023
1 parent 67cccf0 commit 2a0fe67
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cli/yara.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ static bool negate = false;
static bool print_count_only = false;
static bool fail_on_warnings = false;
static bool rules_are_compiled = false;
static bool disable_console_logs = false;
static long total_count = 0;
static long limit = 0;
static long timeout = 1000000;
Expand Down Expand Up @@ -199,6 +200,12 @@ args_option_t options[] = {
_T("define external variable"),
_T("VAR=VALUE")),

OPT_BOOLEAN(
'q',
_T("disable-console-logs"),
&disable_console_logs,
_T("disable printing console log messages")),

OPT_BOOLEAN(
0,
_T("fail-on-warnings"),
Expand Down Expand Up @@ -1245,7 +1252,8 @@ static int callback(
return CALLBACK_CONTINUE;

case CALLBACK_MSG_CONSOLE_LOG:
_tprintf(_T("%" PF_S "\n"), (char*) message_data);
if (!disable_console_logs)
_tprintf(_T("%" PF_S "\n"), (char*) message_data);
return CALLBACK_CONTINUE;
}

Expand Down
4 changes: 4 additions & 0 deletions docs/commandline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ Available options are:

Define external variable. This option can be used multiple times.

.. option:: -q --disable-console-logs

Disable printing console log messages.

.. option:: --fail-on-warnings

Treat warnings as errors. Has no effect if used with --no-warnings.
Expand Down

0 comments on commit 2a0fe67

Please sign in to comment.