Tripal
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Drupal\tripal\Services\TripalLogger Class Reference

Public Member Functions

 __construct ()
 
 setModule ($module)
 
 setJob (\Drupal\tripal\Services\TripalJob $job)
 
 notice ($message, $context=[], $options=[])
 
 info ($message, $context=[], $options=[])
 
 error ($message, $context=[], $options=[])
 
 warning ($message, $context=[], $options=[])
 
 emergency ($message, $context=[], $options=[])
 
 alert ($message, $context=[], $options=[])
 
 critical ($message, $context=[], $options=[])
 
 debug ($message, $context=[], $options=[])
 
 log ($level, $message, $context=[], $options=[])
 

Protected Member Functions

 initLogger ()
 
 isSuppressed ()
 
 log2Job ($message, $context=[])
 
 log2Server ($message, $context, $options)
 
 log2Message ($level, $message, $context=[])
 
 messageString ($message, $context)
 

Protected Attributes

 $logger
 
 $module = 'tripal'
 
 $job = NULL
 

Constructor & Destructor Documentation

◆ __construct()

Drupal\tripal\Services\TripalLogger::__construct ( )

Constructor: initialize connections.

Member Function Documentation

◆ alert()

Drupal\tripal\Services\TripalLogger::alert (   $message,
  $context = [],
  $options = [] 
)

Logs an alert message.

A prefix of "ALERT: " is added to the message to Tripal jobs.

Logs to:

  • Drupal Logger (unless specified in options)
  • Tripal Job log
  • Server log
  • Drupal Message (if specified in options)
Parameters
$messageThe message MUST be a string or object implementing __toString().
$contextThe message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo". The context array can contain arbitrary data. The only assumption that can be made by implementors is that if an Exception instance is given to produce a stack trace, it MUST be in a key named "exception".
$optionsAn array of options where the following keys are supported:
  • drupal_set_message: set to TRUE if this message should also be shown as a message for the user to see on the page.
  • logger: set to FALSE if this message should not be sent to the Drupal logger.
  • first_progress_bar: this should be used for the first log call for a progress bar.
  • is_progress_bar: this option should be used for all but the first print of a progress bar to allow it all to be printed on the same line without intervening date prefixes.

◆ critical()

Drupal\tripal\Services\TripalLogger::critical (   $message,
  $context = [],
  $options = [] 
)

Logs a crtical message.

A prefix of "CRITICAL: " is added to the message to Tripal jobs.

Logs to:

  • Drupal Logger (unless specified in options)
  • Tripal Job log
  • Server log
  • Drupal Message (if specified in options)
Parameters
$messageThe message MUST be a string or object implementing __toString().
$contextThe message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo". The context array can contain arbitrary data. The only assumption that can be made by implementors is that if an Exception instance is given to produce a stack trace, it MUST be in a key named "exception".
$optionsAn array of options where the following keys are supported:
  • drupal_set_message: set to TRUE if this message should also be shown as a message for the user to see on the page.
  • logger: set to FALSE if this message should not be sent to the Drupal logger.
  • first_progress_bar: this should be used for the first log call for a progress bar.
  • is_progress_bar: this option should be used for all but the first print of a progress bar to allow it all to be printed on the same line without intervening date prefixes.

◆ debug()

Drupal\tripal\Services\TripalLogger::debug (   $message,
  $context = [],
  $options = [] 
)

Logs a debug message.

A prefix of "DEBUG: " is added to the message to Tripal jobs.

Logs to:

  • Drupal Logger (unless specified in options)
  • Tripal Job log
  • Server log
  • Drupal Message (if specified in options)

For Tripal 3, no debug messages were logged unless the TRIPAL_DEBUG environment variable is set. Under Tripal 4, debug messages are always printed.

Parameters
$messageThe message MUST be a string or object implementing __toString().
$contextThe message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo". The context array can contain arbitrary data. The only assumption that can be made by implementors is that if an Exception instance is given to produce a stack trace, it MUST be in a key named "exception".
$optionsAn array of options where the following keys are supported:
  • logger: set to FALSE if this message should not be sent to the Drupal logger.
  • first_progress_bar: this should be used for the first log call for a progress bar.
  • is_progress_bar: this option should be used for all but the first print of a progress bar to allow it all to be printed on the same line without intervening date prefixes.

◆ emergency()

Drupal\tripal\Services\TripalLogger::emergency (   $message,
  $context = [],
  $options = [] 
)

Logs an emergency message.

A prefix of "EMERGENCY: " is added to the message to Tripal jobs.

Logs to:

  • Drupal Logger (unless specified in options)
  • Tripal Job log
  • Server log
  • Drupal Message (if specified in options)
Parameters
$messageThe message MUST be a string or object implementing __toString().
$contextThe message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo". The context array can contain arbitrary data. The only assumption that can be made by implementors is that if an Exception instance is given to produce a stack trace, it MUST be in a key named "exception".
$optionsAn array of options where the following keys are supported:
  • drupal_set_message: set to TRUE if this message should also be shown as a message for the user to see on the page.
  • logger: set to FALSE if this message should not be sent to the Drupal logger.
  • first_progress_bar: this should be used for the first log call for a progress bar.
  • is_progress_bar: this option should be used for all but the first print of a progress bar to allow it all to be printed on the same line without intervening date prefixes.

◆ error()

Drupal\tripal\Services\TripalLogger::error (   $message,
  $context = [],
  $options = [] 
)

Logs an error message.

A prefix of "ERROR: " is added to the message to Tripal jobs.

Logs to:

  • Drupal Logger (unless specified in options)
  • Tripal Job log
  • Server log
  • Drupal Message (if specified in options)
Parameters
$messageThe message MUST be a string or object implementing __toString().
$contextThe message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo". The context array can contain arbitrary data. The only assumption that can be made by implementors is that if an Exception instance is given to produce a stack trace, it MUST be in a key named "exception".
$optionsAn array of options where the following keys are supported:
  • drupal_set_message: set to TRUE if this message should also be shown as a message for the user to see on the page.
  • logger: set to FALSE if this message should not be sent to the Drupal logger.
  • first_progress_bar: this should be used for the first log call for a progress bar.
  • is_progress_bar: this option should be used for all but the first print of a progress bar to allow it all to be printed on the same line without intervening date prefixes.

◆ info()

Drupal\tripal\Services\TripalLogger::info (   $message,
  $context = [],
  $options = [] 
)

Logs an info message.

Logs to:

  • Drupal Logger (unless specified in options)
  • Tripal Job log
  • Drupal Message (if specified in options)
Parameters
$messageThe message MUST be a string or object implementing __toString().
$contextThe message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo". The context array can contain arbitrary data. The only assumption that can be made by implementors is that if an Exception instance is given to produce a stack trace, it MUST be in a key named "exception".
$optionsAn array of options where the following keys are supported:
  • drupal_set_message: set to TRUE if this message should also be shown as a message for the user to see on the page.
  • logger: set to FALSE if this message should not be sent to the Drupal logger.

◆ initLogger()

Drupal\tripal\Services\TripalLogger::initLogger ( )
protected

Intiailizes the Drupal logger.

◆ isSuppressed()

Drupal\tripal\Services\TripalLogger::isSuppressed ( )
protected

Checks if error suppression is enabled.

For backwards compatibility with Tripal v3 this function checks the TRIPAL_SUPPRESS_ERRORS environment variable. If it is set then all logging is suppressed even if it is not an "error" message.

◆ log()

Drupal\tripal\Services\TripalLogger::log (   $level,
  $message,
  $context = [],
  $options = [] 
)

A wrapper for the Drupal::Logger log function

Logs to:

  • Drupal Logger (unless specified in options)
  • Tripal Job log
  • Server log if not 'info' or 'notice'
  • Drupal Message (if specified in options)

A prefix indicating the level (other than info and notice messages) is added to the message to Tripal jobs.

Parameters
$levelThe level to log: emergency, critical, alert, error, warning, notice, info, debug.
$messageThe message MUST be a string or object implementing __toString().
$contextThe message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo". The context array can contain arbitrary data. The only assumption that can be made by implementors is that if an Exception instance is given to produce a stack trace, it MUST be in a key named "exception".
$optionsAn array of options where the following keys are supported:
  • drupal_set_message: set to TRUE if this message should also be shown as a message for the user to see on the page.
  • logger: set to FALSE if this message should not be sent to the Drupal logger.
  • first_progress_bar: this should be used for the first log call for a progress bar.
  • is_progress_bar: this option should be used for all but the first print of a progress bar to allow it all to be printed on the same line without intervening date prefixes.

◆ log2Job()

Drupal\tripal\Services\TripalLogger::log2Job (   $message,
  $context = [] 
)
protected

Logs a message directly to the job.

Parameters
$messageThe message MUST be a string or object implementing __toString().
$contextThe message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo". The context array can contain arbitrary data. The only assumption that can be made by implementors is that if an Exception instance is given to produce a stack trace, it MUST be in a key named "exception".

◆ log2Message()

Drupal\tripal\Services\TripalLogger::log2Message (   $level,
  $message,
  $context = [] 
)
protected

Prints the message as a Drupal status message to the page.

Parameters
$levelThe level of the message: critical, error, emergency, alert, warning, info or notice.
$messageThe message MUST be a string or object implementing __toString().
$contextThe message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo". The context array can contain arbitrary data. The only assumption that can be made by implementors is that if an Exception instance is given to produce a stack trace, it MUST be in a key named "exception".

◆ log2Server()

Drupal\tripal\Services\TripalLogger::log2Server (   $message,
  $context,
  $options 
)
protected

Sends the log message to the webserver server logs.

Parameters
$messageThe message MUST be a string or object implementing __toString().
$contextThe message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo". The context array can contain arbitrary data. The only assumption that can be made by implementors is that if an Exception instance is given to produce a stack trace, it MUST be in a key named "exception".

◆ messageString()

Drupal\tripal\Services\TripalLogger::messageString (   $message,
  $context 
)
protected

Converts the logged message into a full string

Performs replacmeent of the tokens in the message with the values in the context array.

Parameters
$messageThe message MUST be a string or object implementing __toString().
$contextThe message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo". The context array can contain arbitrary data. The only assumption that can be made by implementors is that if an Exception instance is given to produce a stack trace, it MUST be in a key named "exception".

◆ notice()

Drupal\tripal\Services\TripalLogger::notice (   $message,
  $context = [],
  $options = [] 
)

Logs a notice message.

Logs to:

  • Drupal Logger (unless specified in options)
  • Tripal Job log
  • Drupal Message (if specified in options)
Parameters
$messageThe message MUST be a string or object implementing __toString().
$contextThe message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo". The context array can contain arbitrary data. The only assumption that can be made by implementors is that if an Exception instance is given to produce a stack trace, it MUST be in a key named "exception".
$optionsAn array of options where the following keys are supported:
  • drupal_set_message: set to TRUE if this message should also be shown as a message for the user to see on the page.
  • logger: set to FALSE if this message should not be sent to the Drupal logger.

◆ setJob()

Drupal\tripal\Services\TripalLogger::setJob ( \Drupal\tripal\Services\TripalJob  $job)

A setter for the job object if this class is being run using a Tripal job.

◆ setModule()

Drupal\tripal\Services\TripalLogger::setModule (   $module)

Set the name of the module that should be used for logging.

Parameters
$moduleThe module name.

◆ warning()

Drupal\tripal\Services\TripalLogger::warning (   $message,
  $context = [],
  $options = [] 
)

Logs a warning message.

A prefix of "WARNING: " is added to the message to Tripal jobs.

Logs to:

  • Drupal Logger (unless specified in options)
  • Tripal Job log
  • Server log
  • Drupal Message (if specified in options)
Parameters
$messageThe message MUST be a string or object implementing __toString().
$contextThe message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo". The context array can contain arbitrary data. The only assumption that can be made by implementors is that if an Exception instance is given to produce a stack trace, it MUST be in a key named "exception".
$optionsAn array of options where the following keys are supported:
  • drupal_set_message: set to TRUE if this message should also be shown as a message for the user to see on the page.
  • logger: set to FALSE if this message should not be sent to the Drupal logger.
  • first_progress_bar: this should be used for the first log call for a progress bar.
  • is_progress_bar: this option should be used for all but the first print of a progress bar to allow it all to be printed on the same line without intervening date prefixes.

Member Data Documentation

◆ $job

Drupal\tripal\Services\TripalLogger::$job = NULL
protected

Holds the Job object

◆ $logger

Drupal\tripal\Services\TripalLogger::$logger
protected

The drupal logger object.

◆ $module

Drupal\tripal\Services\TripalLogger::$module = 'tripal'
protected

The module for which messages should be logged


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