Difference between revisions of "Freeside:3:Documentation:Developer/FS/Log"
From Freeside
m (Edit via perl MediaWiki framework (1.13)) |
m (Edit via perl MediaWiki framework (1.13)) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 20: | Line 20: | ||
==CLASS METHODS== | ==CLASS METHODS== | ||
− | + | :new CONTEXT | |
+ | |||
:Constructs and returns a log handle. CONTEXT must be a known context tag indicating what activity is going on, such as the name of the function or script that is executing. | :Constructs and returns a log handle. CONTEXT must be a known context tag indicating what activity is going on, such as the name of the function or script that is executing. | ||
:Log context is a stack, and each element is removed from the stack when it goes out of scope. So don't keep log handles in persistent places (i.e. package variables or class-scoped lexicals). | :Log context is a stack, and each element is removed from the stack when it goes out of scope. So don't keep log handles in persistent places (i.e. package variables or class-scoped lexicals). | ||
− | + | ||
+ | :context | ||
+ | |||
:Returns the current context stack. | :Returns the current context stack. | ||
− | + | ||
+ | :log LEVEL, MESSAGE[, OPTIONS ] | ||
+ | |||
:Like [[Freeside:3:Documentation:Developer/Log/Dispatch/log|Log::Dispatch::log]], but OPTIONS may include: | :Like [[Freeside:3:Documentation:Developer/Log/Dispatch/log|Log::Dispatch::log]], but OPTIONS may include: | ||
:- agentnum - object (an <FS::Record> object to reference in this log message) - tablename and tablenum (an alternate way of specifying 'object') | :- agentnum - object (an <FS::Record> object to reference in this log message) - tablename and tablenum (an alternate way of specifying 'object') | ||
+ | |||
+ | ==POD ERRORS== | ||
+ | Hey! '''The above document had some coding errors, which are explained below:''' | ||
+ | |||
+ | ; Around line 50: | ||
+ | :You can't have =items (as at line 78) unless the first thing after the =over is an =item |
Latest revision as of 10:01, 10 April 2015
NAME
FS::Log - Freeside event log
SYNOPSIS
use FS::Log;
sub do_something { my $log = FS::Log->new('do_something'); # set log context to 'do_something'
... if ( $error ) { $log->error('something is wrong: '.$error); return $error; } # at this scope exit, do_something is removed from context
}
DESCRIPTION
FS::Log provides an interface for logging errors and profiling information to the database. FS::Log inherits from Log::Dispatch.
CLASS METHODS
- new CONTEXT
- Constructs and returns a log handle. CONTEXT must be a known context tag indicating what activity is going on, such as the name of the function or script that is executing.
- Log context is a stack, and each element is removed from the stack when it goes out of scope. So don't keep log handles in persistent places (i.e. package variables or class-scoped lexicals).
- context
- Returns the current context stack.
- log LEVEL, MESSAGE[, OPTIONS ]
- Like Log::Dispatch::log, but OPTIONS may include:
- - agentnum - object (an <FS::Record> object to reference in this log message) - tablename and tablenum (an alternate way of specifying 'object')
POD ERRORS
Hey! The above document had some coding errors, which are explained below:
- Around line 50:
- You can't have =items (as at line 78) unless the first thing after the =over is an =item