GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Log::Contextual::TeeLogger(3) User Contributed Perl Documentation Log::Contextual::TeeLogger(3)

Log::Contextual::TeeLogger - Output to more than one logger

version 0.009001

  use Log::Contextual::SimpleLogger;
  use Log::Contextual::TeeLogger;
  use Log::Contextual qw( :log ),
    -logger => Log::Contextual::TeeLogger->new({ loggers => [
      Log::Contextual::SimpleLogger->new({ levels => [ 'debug' ] }),
      Log::Contextual::SimpleLogger->new({
        levels => [ 'info' ],
        coderef => sub { print @_ },
      }),
    ]});
  ## docs below here not yet edited
  log_info { 'program started' }; # no-op because info is not in levels
  sub foo {
    log_debug { 'entered foo' };
    ...
  }

This module is a simple logger made mostly for demonstration and initial experimentation with Log::Contextual. We recommend you use a real logger instead. For something more serious but not overly complicated, take a look at Log::Dispatchouli.

Arguments: "Dict[ levels => ArrayRef[Str], coderef => Optional[CodeRef] ] $conf"

  my $l = Log::Contextual::SimpleLogger->new({
    levels => [qw( info warn )],
    coderef => sub { print @_ }, # the default prints to STDERR
  });

Creates a new SimpleLogger object with the passed levels enabled and optionally a "CodeRef" may be passed to modify how the logs are output/stored.

Levels may contain:

  trace
  debug
  info
  warn
  error
  fatal

Arguments: @anything

All of the following six methods work the same. The basic pattern is:

  sub $level {
    my $self = shift;
    print STDERR "[$level] " . join qq{\n}, @_;
        if $self->is_$level;
  }

trace

  $l->trace( 'entered method foo with args ' join q{,}, @args );

debug

  $l->debug( 'entered method foo' );

info

  $l->info( 'started process foo' );

warn

  $l->warn( 'possible misconfiguration at line 10' );

error

  $l->error( 'non-numeric user input!' );

fatal

  $l->fatal( '1 is never equal to 0!' );

Note: "fatal" does not call "die" for you, see "EXCEPTIONS AND ERROR HANDLING" in Log::Contextual

All of the following six functions just return true if their respective level is enabled.

is_trace

  say 'tracing' if $l->is_trace;

is_debug

  say 'debuging' if $l->is_debug;

is_info

  say q{info'ing} if $l->is_info;

is_warn

  say 'warning' if $l->is_warn;

is_error

  say 'erroring' if $l->is_error;

is_fatal

  say q{fatal'ing} if $l->is_fatal;

Please report any bugs or feature requests on the bugtracker website <https://github.com/haarg/Log-Contextual/issues>

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>

This software is copyright (c) 2024 by Arthur Axel "fREW" Schmidt.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

2024-05-29 perl v5.40.2

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.