Odyssey
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Logger Class Reference
Inheritance diagram for Logger:
StandardLogger TestLogger ColorStandardLogger

Public Member Functions

 __construct ($name="root", $pDevMode=false)
 
 debug (... $msg)
 
 info (... $msg)
 
 warning (... $msg)
 
 notice (... $msg)
 
 error (... $msg)
 

Protected Member Functions

 log ($level, $log)
 
 log_format ($level,... $args)
 

Private Attributes

 $devMode = false
 

Detailed Description

Definition at line 9 of file logging.i.

Member Function Documentation

◆ debug()

Logger::debug (   $msg)

(3/6/18) - Debug prints should not make it to production. The intent of debug is purely for debugging development code. If you would like to dump extra information to the log to better track down error in production then use either info or error

Definition at line 52 of file logging.i.

52  {
53  /**
54  * (3/6/18) - Debug prints should not make it to production.
55  * The intent of debug is purely for debugging development code.
56  * If you would like to dump extra information to the log to better track down
57  * error in production then use either
58  * info or
59  * error
60  */
61  if ($this->devMode) {
62  return $this->log_format('DEBUG', ...$msg);
63  }
64  }
log_format($level,... $args)
Definition: logging.i:25

◆ log_format()

Logger::log_format (   $level,
  $args 
)
protected

args can be a variable number of messages. ONLY 1 then this is the only message and there is no extra formatting

1

This option will format the string, based on the printf format, which should be the first argument in that array ** NOTE using [] is short notation for declaring an array For example $logger->info("%s %s", "Print this String", "Then this string");

Definition at line 25 of file logging.i.

25  {
26  /**
27  * args can be a variable number of messages.
28  * ONLY 1
29  * then this is the only message and there is no extra formatting
30  *
31  * > 1
32  * This option will format the string, based on the printf format, which should be the first argument in that array
33  * ** NOTE using [] is short notation for declaring an array
34  * For example $logger->info("%s %s", "Print this String", "Then this string");
35  *
36  */
37  if (count($args) == 1) {
38  $logMsg = array_shift($args);
39  } else {
40  // ** First argument is the format
41  // ** Remaining arguments will be used in the vsprintf function
42  // ** However, if there aren't enough items in the array to match the printf formatting %
43  // ** then an error is thrown. Trying to catch that here. And then just print out the array elements as a string
44  // *** NOTE: When using this method a warning will be raised if you have less arguments than formats % for vsprintf
45  $fmt = array_shift($args);
46  $logMsg = vsprintf($fmt, $args);
47  }
48  // pass string to log function and return response
49  return $this->log($level, $logMsg);
50  }

Member Data Documentation

◆ $devMode

Logger::$devMode = false
private

devMode – Is the environment currently set to be in dev mode? {true, false (default)}

Definition at line 15 of file logging.i.


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