Codex

Log::Message::Simple

Section: User Contributed Perl Documentation (3pm)

Updated: 2013-01-23

Index?action=index Return to Main Contents


NAME

Log::Message::Simple - Simplified interface to Log::Message

SYNOPSIS

use Log::Message::Simple qw[msg error debug carp croak cluck confess];

use Log::Message::Simple qw[:STD :CARP];

### standard reporting functionality msg( "Connecting to database", $verbose ); error( "Database connection failed: $@", $verbose ); debug( "Connection arguments were: $args", $debug );

### standard carp functionality carp( "Wrong arguments passed: @_" ); croak( "Fatal: wrong arguments passed: @_" ); cluck( "Wrong arguments passed -- including stacktrace: @_" ); confess("Fatal: wrong arguments passed -- including stacktrace: @_" );

### retrieve individual message my @stack = Log::Message::Simple->stack; my @stack = Log::Message::Simple->flush;

### retrieve the entire stack in printable form my $msgs = Log::Message::Simple->stack_as_string; my $trace = Log::Message::Simple->stack_as_string?(1);

### redirect output local $Log::Message::Simple::MSG_FH = \*STDERR; local $Log::Message::Simple::ERROR_FH = \*STDERR; local $Log::Message::Simple::DEBUG_FH = \*STDERR;

### force a stacktrace on error local $Log::Message::Simple::STACKTRACE_ON_ERROR = 1

@]

DESCRIPTION

This module provides standardized logging facilities using the module.

FUNCTIONS

msg(message string [,VERBOSE])

Records a message on the stack, and prints it to (or actually , see the section below), if the option is true. The option defaults to false.
Exported by default, or using the tag.

debug(message string [,VERBOSE])

Records a debug message on the stack, and prints it to (or actually , see the section below), if the option is true. The option defaults to false.
Exported by default, or using the tag.

error(error string [,VERBOSE])

Records an error on the stack, and prints it to (or actually , see the sections below), if the option is true. The options defaults to true.
Exported by default, or using the tag.

carp();

Provides functionality equal to while still logging to the stack.
Exported by using the tag.

croak();

Provides functionality equal to while still logging to the stack.
Exported by using the tag.

confess();

Provides functionality equal to while still logging to the stack.
Exported by using the tag.

cluck();

Provides functionality equal to while still logging to the stack.
Exported by using the tag.

CLASS METHODS

Log::Message::Simple->stack()

Retrieves all the items on the stack. Since is implemented using , consult its manpage for the function to see what is returned and how to use the items.

Log::Message::Simple->stack_as_string([TRACE])

Returns the whole stack as a printable string. If the option is true all items are returned with output, rather than just the message. defaults to false.

Log::Message::Simple->flush()

Removes all the items from the stack and returns them. Since is implemented using , consult its manpage for the function to see what is returned and how to use the items.

GLOBAL VARIABLES

$ERROR_FH
This is the filehandle all the messages sent to are being printed. This defaults to .:
$MSG_FH
This is the filehandle all the messages sent to are being printed. This default to .:
$DEBUG_FH
This is the filehandle all the messages sent to are being printed. This default to .:
$STACKTRACE_ON_ERROR
If this option is set to , every call to will generate a stacktrace using . Defaults to :

Index

NAME

SYNOPSIS

DESCRIPTION

FUNCTIONS

msg(message string [,VERBOSE])

debug(message string [,VERBOSE])

error(error string [,VERBOSE])

carp();

croak();

confess();

cluck();

CLASS METHODS

Log::Message::Simple->stack()

Log::Message::Simple->stack_as_string([TRACE])

Log::Message::Simple->flush()

GLOBAL VARIABLES