File: inner-adapter.t

package info (click to toggle)
liblog-any-perl 1.717-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 448 kB
  • sloc: perl: 1,499; makefile: 11
file content (28 lines) | stat: -rw-r--r-- 650 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use strict;
use warnings;
use Test::More;

plan tests => 2;

our $BUF;

package MyApp::Log::Adapter;
use base qw(Log::Any::Adapter::Base);
foreach my $method ( Log::Any->logging_methods() ) {
    no strict 'refs';
    *$method = sub { $main::BUF .= "$_[1]\n"};
}
foreach my $method ( Log::Any->detection_methods() ) {
    no strict 'refs';
    *$method = sub { 1 };
}

package main;
use Log::Any::Adapter;
eval { Log::Any::Adapter->set('+MyApp::Log::Adapter') };
is( $@, "", "setting inner package as adapter is OK");

my $log = Log::Any->get_logger;

$log->critical("DIE DIE DIE");
is( $BUF, "DIE DIE DIE\n", "logged a message via inner adapter" );