Skip to content

Commit

Permalink
Add option to ignore empty context in monolog (#233)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecofishrcr authored and PabloKowalczyk committed Apr 4, 2020
1 parent dd5fe12 commit 75ba071
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,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 @@ -114,11 +114,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

0 comments on commit 75ba071

Please sign in to comment.