Skip to content

Commit

Permalink
use the INVOCATION_ID environment variable too
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Jul 9, 2017
1 parent 95debd4 commit 8716d77
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Changes
@@ -1,6 +1,8 @@

7.36 2017-07-08
7.36 2017-07-09
- Fixed basename method in Mojo::File to work with relative paths. (jberger)
- Fixed a bug where Mojo::Log could not correctly identify if it was deployed
with systemd.
- Fixed Mojo::HelloWorld to actually be a Mojolicious subclass.

7.35 2017-07-05
Expand Down
5 changes: 3 additions & 2 deletions lib/Mojo/Log.pm
Expand Up @@ -19,7 +19,8 @@ has history => sub { [] };
has level => 'debug';
has max_history_size => 10;
has 'path';
has short => sub { $ENV{JOURNAL_STREAM} && !shift->path };
has short =>
sub { $ENV{INVOCATION_ID} && $ENV{JOURNAL_STREAM} && !shift->path };

# Supported log levels
my %LEVEL = (debug => 1, info => 2, warn => 3, error => 4, fatal => 5);
Expand Down Expand Up @@ -178,7 +179,7 @@ Log file path used by L</"handle">.
Generate short log messages without a timestamp, suitable for systemd, defaults
to auto-detection based on the presence of a L</"path"> and the
C<JOURNAL_STREAM> environment variable.
C<INVOCATION_ID> and C<JOURNAL_STREAM> environment variables.
=head1 METHODS
Expand Down
1 change: 1 addition & 0 deletions t/mojo/log.t
Expand Up @@ -57,6 +57,7 @@ like $log->format->(time, 'debug', qw(Test 1 2 3)), qr/^debug:\d+:Test:1:2:3$/,
like $log->format->(time, 'debug', 'Test 123'),
qr/^\[.*\] \[debug\] Test 123\n$/, 'right format';
local $ENV{JOURNAL_STREAM} = '1:23456';
local $ENV{INVOCATION_ID} = 1;
$log = Mojo::Log->new;
ok $log->short, 'systemd has been detected';
like $log->format->(time, 'debug', 'Test 123'), qr/^\[debug\] Test 123\n$/,
Expand Down

0 comments on commit 8716d77

Please sign in to comment.