GX::Logger

Module Version: 0.2000_01

NAME

GX::Logger - Default logger component

SYNOPSIS

package MyApp::Logger;

use GX::Logger;

__PACKAGE__->setup(
levels => [ qw( warning error fatal ) ]
);

1;

DESCRIPTION

This module provides the GX::Logger class which extends the GX::Component::Singleton class.

METHODS

Constructor

new

Returns the logger component instance.

$logger = $logger_class->new;
Returns:
Exceptions:

Public Methods

All public methods can be called both as instance and class methods.

debug

Logs the given "debug"-level message(s).

$logger->debug( @messages );
Arguments:
  • @messages ( strings )

default_level

Returns the default log level.

$level = $logger->default_level;
Returns:
  • $level ( string )

disable

Disables the specified log levels.

$logger->disable( @levels );
Arguments:
  • @levels ( strings )

disable_all

Disables all logging.

$logger->disable_all;

enable

Enables the specified log levels.

$logger->enable( @levels );
Arguments:
  • @levels ( strings )

enable_all

Enables all log levels.

$logger->enable_all;

error

Logs the given "error"-level message(s).

$logger->error( @messages );
Arguments:
  • @messages ( strings )

fatal

Logs the given "fatal"-level message(s).

$logger->fatal( @messages );
Arguments:
  • @messages ( strings )

is_enabled

Returns true if the specified log level is active, otherwise false.

$result = logger->is_enabled( $level );
Returns:
  • $result ( bool )

levels

Returns / sets the active log levels.

@levels = $logger->levels;
@levels = $logger->levels( @levels );
Arguments:
  • @levels ( strings ) [ optional ]
Returns:
  • @levels ( strings )

log

Logs the given message.

$logger->log( $message );
Arguments:
  • $message ( string )

Alternative syntax:

$logger->log( $level, @messages );
Arguments:
  • $level ( string )
  • @messages ( strings )

notice

Logs the given "notice"-level message(s).

$logger->notice( @messages );
Arguments:
  • @messages ( strings )

setup

Sets up the logger.

$class->setup( %options );
Options:
  • default_level ( string )

    The default log level. Defaults to "notice".

  • levels ( ARRAY reference )

    The active log levels.

Exceptions:

trace

Logs the given "trace"-level message(s).

$logger->trace( @messages );
Arguments:
  • @messages ( strings )

warning

Logs the given "warning"-level message(s).

$logger->warning( @messages );
Arguments:
  • @messages ( strings )

USAGE

Output

By default, all messages are written to STDERR.

Log Levels

All log levels, listed in order of increasing importance:

trace
debug
notice
warning
error
fatal

AUTHOR

Jörg A. Uzarek <uzarek@runlevelnull.de>

COPYRIGHT AND LICENSE

Copyright © 2009-2011 Jörg A. Uzarek.

This module is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License Version 3 as published by the Free Software Foundation.