CInbox (Common-Inbox)  0.1
Common functionality for ingesting files for archiving.
Public Member Functions | Public Attributes | Static Public Attributes
Logger Class Reference

List of all members.

Public Member Functions

 addOutputOption ($output, $logLevel, $prefixes, $showTimestamp=false, $showInstanceId=false)
 setOutputOption ($output, $option, $value)
 getPrefixShort ()
 getPrefixLong ()
 getPrefixScreen ()
 setLogfile ($filename)
 showTimestamp ($flag)
 showInstanceId ($flag)
 addMessage ($logLevel, $message, $source=null, $lineNumber=null)
 outputMsgBuffer ()
 printToScreen ($lines)
 writeToLogfile ($lines)
 formatAsText ($msgBuffer, $targetlogLevel, $prefixes)
 logAlways ($msg)
 logError ($msg)
 logWarning ($msg)
 logMsg ($msg)
 logInfo ($msg)
 logDebug ($msg)
 logException ($msg, $e)
 logErrorPhp ($msg)
 logNewline ($lines=1)
 logHeader ($msg)
 getHeadline ($char=self::HEADLINE_CHAR1, $width=self::HEADLINE_WIDTH1)
 getTimestamp ($format=null)
 setLogLevel ($output, $logLevel)

Public Attributes

const LEVEL_NONE = 0
const LEVEL_DEBUG = 1
const LEVEL_INFO = 2
const LEVEL_NORMAL = 3
const LEVEL_WARNING = 5
const LEVEL_ALWAYS = 10
const LEVEL_ERROR = 20
const OUT_SCREEN = 1
const OUT_TEXTFILE = 2
const OUT_OPT_LOGLEVEL = 0
const OUT_OPT_PREFIXES = 1
const OUT_OPT_TIMESTAMPS = 2
const OUT_OPT_INSTANCEID = 3
const HEADLINE_CHAR1 = '='
const HEADLINE_CHAR2 = '-'
const HEADLINE_CHAR3 = '+'
const HEADLINE_WIDTH1 = 60

Static Public Attributes

static $TIMESTAMP_FORMAT = 'Y-m-d\TH:i:s'
static $instanceId

Detailed Description

Handles logging messages to different outputs, such as screen or files. It supports adding a preformatted timestamp, as well as the messages' loglevel to the output.

Additionally it offers a few handy ways of formatting the text output, such as adding a horizontal line, etc.

Author:
Peter Bubestinger-Steindl (pb@av-rd.com)
See also:

Member Function Documentation

Logger::addOutputOption ( output,
logLevel,
prefixes,
showTimestamp = false,
showInstanceId = false 
)

Configure formatting of an output option.

Logger::formatAsText ( msgBuffer,
targetlogLevel,
prefixes 
)

Formats current contents of the message buffer as text and returns it as an array of lines.

Logger::getHeadline ( char = self::HEADLINE_CHAR1,
width = self::HEADLINE_WIDTH1 
)

Returns a horizontal line consisting of '=' characters. Can be used for markdown-style headlines.

Sets long prefixes (=1 word) for each type of log message.

Screen output does not prefix all messages, so it's easier to read. It still prefixes important / irregular messages though, such as errors/warning and debug messages.

Sets short prefixes (=1 letter) for each type of log message.

Logger::getTimestamp ( format = null)

Returns a pre-formatted timestamp string. Default format is self::TIMESTAMP_FORMAT.

Logger::logErrorPhp ( msg)

Logs error message, but adds information from PHP's internal error handler.

error_get_last()

Logger::logException ( msg,
e 
)

Logs the given exception $e as error message.

Logger::logHeader ( msg)

Logs a pre-formatted block that makes it possible to indicate a new logging session.

Logger::logNewline ( lines = 1)

Write an empty line into the logs. Used for visual spacing between entries.

Outputs the current message buffer to different output formats (screen, file, etc). The message buffer is cleared afterwards.

Logger::printToScreen ( lines)

Simply prints the contents of an array of text-lines to the screen.

Logger::writeToLogfile ( lines)

Writes log buffer to a file.


The documentation for this class was generated from the following file:
 All Classes Functions Variables