use Log::Contextual qw{:dlog set_logger};
my $var_log = VarLogger->new;
+set_logger($var_log);
+
+my @foo = Dlog_trace { "Look ma, data: $_" } qw{frew bar baz};
+ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_trace passes data through correctly');
+is( $var_log->var, <<'OUT', 'Output for Dlog_trace is correct');
+tLook ma, data: "frew"
+"bar"
+"baz"
+OUT
+
+my $bar = DlogS_trace { "Look ma, data: $_" } [qw{frew bar baz}];
+ok( eq_array($bar, [qw{frew bar baz}]), 'DlogS_trace passes data through correctly');
+is( $var_log->var, <<'OUT', 'Output for DlogS_trace is correct');
+tLook ma, data: [
+ "frew",
+ "bar",
+ "baz"
+]
+OUT
+
-set_logger(sub { $var_log });
my @foo = Dlog_debug { "Look ma, data: $_" } qw{frew bar baz};
ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_debug passes data through correctly');
is( $var_log->var, <<'OUT', 'Output for Dlog_debug is correct');
"bar"
"baz"
OUT
+
my $bar = DlogS_debug { "Look ma, data: $_" } [qw{frew bar baz}];
ok( eq_array($bar, [qw{frew bar baz}]), 'DlogS_debug passes data through correctly');
is( $var_log->var, <<'OUT', 'Output for DlogS_debug is correct');
]
OUT
+
+my @foo = Dlog_info { "Look ma, data: $_" } qw{frew bar baz};
+ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_info passes data through correctly');
+is( $var_log->var, <<'OUT', 'Output for Dlog_info is correct');
+iLook ma, data: "frew"
+"bar"
+"baz"
+OUT
+
+my $bar = DlogS_info { "Look ma, data: $_" } [qw{frew bar baz}];
+ok( eq_array($bar, [qw{frew bar baz}]), 'DlogS_info passes data through correctly');
+is( $var_log->var, <<'OUT', 'Output for DlogS_info is correct');
+iLook ma, data: [
+ "frew",
+ "bar",
+ "baz"
+]
+OUT
+
+
+my @foo = Dlog_warn { "Look ma, data: $_" } qw{frew bar baz};
+ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_warn passes data through correctly');
+is( $var_log->var, <<'OUT', 'Output for Dlog_warn is correct');
+wLook ma, data: "frew"
+"bar"
+"baz"
+OUT
+
+my $bar = DlogS_warn { "Look ma, data: $_" } [qw{frew bar baz}];
+ok( eq_array($bar, [qw{frew bar baz}]), 'DlogS_warn passes data through correctly');
+is( $var_log->var, <<'OUT', 'Output for DlogS_warn is correct');
+wLook ma, data: [
+ "frew",
+ "bar",
+ "baz"
+]
+OUT
+
+
+my @foo = Dlog_error { "Look ma, data: $_" } qw{frew bar baz};
+ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_error passes data through correctly');
+is( $var_log->var, <<'OUT', 'Output for Dlog_error is correct');
+eLook ma, data: "frew"
+"bar"
+"baz"
+OUT
+
+my $bar = DlogS_error { "Look ma, data: $_" } [qw{frew bar baz}];
+ok( eq_array($bar, [qw{frew bar baz}]), 'DlogS_error passes data through correctly');
+is( $var_log->var, <<'OUT', 'Output for DlogS_error is correct');
+eLook ma, data: [
+ "frew",
+ "bar",
+ "baz"
+]
+OUT
+
+
+my @foo = Dlog_fatal { "Look ma, data: $_" } qw{frew bar baz};
+ok( eq_array(\@foo, [qw{frew bar baz}]), 'Dlog_fatal passes data through correctly');
+is( $var_log->var, <<'OUT', 'Output for Dlog_fatal is correct');
+fLook ma, data: "frew"
+"bar"
+"baz"
+OUT
+
+my $bar = DlogS_fatal { "Look ma, data: $_" } [qw{frew bar baz}];
+ok( eq_array($bar, [qw{frew bar baz}]), 'DlogS_fatal passes data through correctly');
+is( $var_log->var, <<'OUT', 'Output for DlogS_fatal is correct');
+fLook ma, data: [
+ "frew",
+ "bar",
+ "baz"
+]
+OUT
+
SETWITHLOGGER: {
with_logger $var_logger1 => sub {
- log_debug { 'nothing again!' }
+ log_debug { 'nothing again!' };
+ set_logger(sub { $var_logger3 });
+ log_debug { 'this is a set inside a with' };
};
is( $var_logger1->var, 'dnothing again!',
'inner scoped logger works after using set_logger'
);
+ is( $var_logger3->var, 'dthis is a set inside a with',
+ 'set inside with works'
+ );
+
log_debug { 'frioux!' };
is( $var_logger3->var, 'dfrioux!',
q{set_logger's logger comes back after scoped logger}
);
}
+VANILLA: {
+ log_trace { 'fiSMBoC' };
+ is( $var_logger3->var, 'tfiSMBoC', 'trace works');
+
+ log_debug { 'fiSMBoC' };
+ is( $var_logger3->var, 'dfiSMBoC', 'debug works');
+
+ log_info { 'fiSMBoC' };
+ is( $var_logger3->var, 'ifiSMBoC', 'info works');
+
+ log_warn { 'fiSMBoC' };
+ is( $var_logger3->var, 'wfiSMBoC', 'warn works');
+
+ log_error { 'fiSMBoC' };
+ is( $var_logger3->var, 'efiSMBoC', 'error works');
+
+ log_fatal { 'fiSMBoC' };
+ is( $var_logger3->var, 'ffiSMBoC', 'fatal works');
+
+}
+
ok(!eval { Log::Contextual->import; 1 }, 'Blank Log::Contextual import dies');