55 public static function log( $message, $priority = LOG_INFO, $label =
null ) {
56 if ( static::$inst ==
null ) {
57 static::$inst =
new Logger();
60 static::$inst->logString( $message, $priority,
$label );
72 public static function logEx( Exception $ex, $additionalText =
'', $priority = LOG_ERR, $label =
null ) {
73 if ( static::$inst ==
null ) {
74 static::$inst =
new Logger();
78 $msg[] = get_class( $ex );
80 if ( $additionalText !=
'' ) {
81 $msg[] = $additionalText;
85 $msg[] = $ex->getFile() .
':' . $ex->getLine();
87 $msg[] = $ex->getMessage();
88 $msg[] =
'; Trace ->';
89 $msg[] = json_encode( $ex->getTrace() );
91 static::$inst->logString( implode(
' ', $msg ), $priority,
$label );
124 static::$label[] =
$label;
132 array_pop( static::$label );
141 private function logString( $msgText, $pri, $label =
null ) {
142 global $wgFundraisingEmailUnsubscribeLogFacility;
144 if ( static::$context !=
'' ) {
145 $msg[] =
'(' . static::$context .
')';
151 } elseif ( end( static::$label ) !=
'' ) {
152 $msg[] = end( static::$label );
157 openlog( static::$bucket, LOG_ODELAY, $wgFundraisingEmailUnsubscribeLogFacility );
158 syslog( $pri, implode(
' ', $msg ) );
Methods for logging stuff to Syslog.
static logEx(Exception $ex, $additionalText='', $priority=LOG_ERR, $label=null)
Log an exception to Syslog.
static setContext( $context)
A string that will be added to the front of every log message regardless of the current label.
static string $context
A persistent string prepended to all messages.
static string $bucket
What process to tell syslog the message came from.
static pushLabel( $label)
By pushing a label, you change the sub identifier string for each message logged after the string was...
logString( $msgText, $pri, $label=null)
Perform the actual log operation.
static log( $message, $priority=LOG_INFO, $label=null)
Log a message string to Syslog.
static setBucket( $bucket)
Set the process Syslog thinks this is.
static string[] $label
A stack of strings, whatever is on the top of the stack will get prepended to the message.
static self $inst
The global instance of the Syslog class.
static popLabel()
Go back to the last label.