MediaWiki fundraising/REL1_35
Logger Class Reference

Methods for logging stuff to Syslog. More...

Static Public Member Functions

static log ( $message, $priority=LOG_INFO, $label=null)
 Log a message string to Syslog.
 
static logEx (Exception $ex, $additionalText='', $priority=LOG_ERR, $label=null)
 Log an exception to Syslog.
 
static popLabel ()
 Go back to the last label.
 
static pushLabel ( $label)
 By pushing a label, you change the sub identifier string for each message logged after the string was pushed.
 
static setBucket ( $bucket)
 Set the process Syslog thinks this is.
 
static setContext ( $context)
 A string that will be added to the front of every log message regardless of the current label.
 

Private Member Functions

 __construct ()
 
 logString ( $msgText, $pri, $label=null)
 Perform the actual log operation.
 

Static Private Attributes

static string $bucket = ''
 What process to tell syslog the message came from.
 
static string $context = ''
 A persistent string prepended to all messages.
 
static self $inst = null
 The global instance of the Syslog class.
 
static string[] $label = [ '' ]
 A stack of strings, whatever is on the top of the stack will get prepended to the message.
 

Detailed Description

Methods for logging stuff to Syslog.

Definition at line 32 of file Logger.php.

Constructor & Destructor Documentation

◆ __construct()

Logger::__construct ( )
private

Definition at line 44 of file Logger.php.

Member Function Documentation

◆ log()

static Logger::log ( $message,
$priority = LOG_INFO,
$label = null )
static

Log a message string to Syslog.

Parameters
string$messageThe string to log
int$priorityThe syslog priority to log this message at
string | null$labelWhen pushing/popping a label would be too much work

Definition at line 55 of file Logger.php.

◆ logEx()

static Logger::logEx ( Exception $ex,
$additionalText = '',
$priority = LOG_ERR,
$label = null )
static

Log an exception to Syslog.

The stack trace will be included as a JSON string.

Parameters
Exception$exThe exception
string$additionalTextAny string to also log as context, default is empty
int$priorityThe syslog priority to log this message at, default ERR
string | null$labelWhen pushing/popping a label would be too much work

Definition at line 72 of file Logger.php.

◆ logString()

Logger::logString ( $msgText,
$pri,
$label = null )
private

Perform the actual log operation.

Parameters
string$msgText
int$pri
string | null$label

Definition at line 141 of file Logger.php.

◆ popLabel()

static Logger::popLabel ( )
static

Go back to the last label.

Definition at line 131 of file Logger.php.

◆ pushLabel()

static Logger::pushLabel ( $label)
static

By pushing a label, you change the sub identifier string for each message logged after the string was pushed.

Parameters
string$label

Definition at line 123 of file Logger.php.

◆ setBucket()

static Logger::setBucket ( $bucket)
static

Set the process Syslog thinks this is.

This is just a string that gets prepended to the log message by the Syslog utility. Can be used for very cheap bucketing of logs.

Parameters
string$bucket

Definition at line 101 of file Logger.php.

◆ setContext()

static Logger::setContext ( $context)
static

A string that will be added to the front of every log message regardless of the current label.

Use it for things like request IDs.

Parameters
string$context

Definition at line 112 of file Logger.php.

Member Data Documentation

◆ $bucket

string Logger::$bucket = ''
staticprivate

What process to tell syslog the message came from.

Definition at line 38 of file Logger.php.

◆ $context

string Logger::$context = ''
staticprivate

A persistent string prepended to all messages.

Definition at line 40 of file Logger.php.

◆ $inst

self Logger::$inst = null
staticprivate

The global instance of the Syslog class.

Definition at line 35 of file Logger.php.

◆ $label

string [] Logger::$label = [ '' ]
staticprivate

A stack of strings, whatever is on the top of the stack will get prepended to the message.

Definition at line 42 of file Logger.php.


The documentation for this class was generated from the following file: