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 option to ignore empty context in monolog #233

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ output_log_file:
# Set the value to true to allow them.
log_allow_line_breaks: false

# By default empty context arrays are shown in the log.
# Set the value to true to remove them.
log_ignore_empty_context: false

# This option determines whether the output should be emailed or not.
email_output: false

Expand Down
4 changes: 4 additions & 0 deletions resources/config/crunz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ output_log_file: ~
# Set the value to true to allow them.
log_allow_line_breaks: false

# By default empty context arrays are shown in the log.
# Set the value to true to remove them.
log_ignore_empty_context: false

# This option determines whether the output should be emailed or not.
email_output: false

Expand Down
5 changes: 5 additions & 0 deletions src/Configuration/Definition.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public function getConfigTreeBuilder(): TreeBuilder
->info('Flag for line breaks in logs' . PHP_EOL)
->end()

->scalarNode('log_ignore_empty_context')
->defaultFalse()
->info('Flag for empty context in logs' . PHP_EOL)
->end()

->scalarNode('email_output')
->defaultFalse()
->info('Email the event\'s output' . PHP_EOL)
Expand Down
6 changes: 5 additions & 1 deletion src/Logger/Logger.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,15 @@ protected function getDefaultFormatter()
->get('log_allow_line_breaks')
;

$ignoreEmptyContext = $this->configuration
->get('log_ignore_empty_context')
;

return new LineFormatter(
null,
null,
$allowLinebreaks,
false
$ignoreEmptyContext
);
}

Expand Down
1 change: 1 addition & 0 deletions tests/crunz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ errors_log_file: ~
log_output: false
output_log_file: ~
log_allow_line_breaks: false
log_ignore_empty_context: false
email_output: false
email_errors: false
mailer:
Expand Down