Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CLI flag for disabling console log printing. #1915

Merged
merged 1 commit into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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