AloFramework Logger
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • AloFramework
    • Log
  • None
  • PHP
  • Psr
    • Log

Classes

  • AbstractLogger
  • LogLevel
  • NullLogger

Interfaces

  • LoggerAwareInterface
  • LoggerInterface

Traits

  • LoggerAwareTrait
  • LoggerTrait

Exceptions

  • InvalidArgumentException
  1 <?php
  2 
  3 namespace Psr\Log;
  4 
  5 /**
  6  * This is a simple Logger trait that classes unable to extend AbstractLogger
  7  * (because they extend another class, etc) can include.
  8  *
  9  * It simply delegates all log-level-specific methods to the `log` method to 
 10  * reduce boilerplate code that a simple Logger that does the same thing with 
 11  * messages regardless of the error level has to implement.
 12  */
 13 trait LoggerTrait
 14 {
 15     /**
 16      * System is unusable.
 17      *
 18      * @param string $message
 19      * @param array $context
 20      * @return null
 21      */
 22     public function emergency($message, array $context = array())
 23     {
 24         $this->log(LogLevel::EMERGENCY, $message, $context);
 25     }
 26 
 27     /**
 28      * Action must be taken immediately.
 29      *
 30      * Example: Entire website down, database unavailable, etc. This should
 31      * trigger the SMS alerts and wake you up.
 32      *
 33      * @param string $message
 34      * @param array $context
 35      * @return null
 36      */
 37     public function alert($message, array $context = array())
 38     {
 39         $this->log(LogLevel::ALERT, $message, $context);
 40     }
 41 
 42     /**
 43      * Critical conditions.
 44      *
 45      * Example: Application component unavailable, unexpected exception.
 46      *
 47      * @param string $message
 48      * @param array $context
 49      * @return null
 50      */
 51     public function critical($message, array $context = array())
 52     {
 53         $this->log(LogLevel::CRITICAL, $message, $context);
 54     }
 55 
 56     /**
 57      * Runtime errors that do not require immediate action but should typically
 58      * be logged and monitored.
 59      *
 60      * @param string $message
 61      * @param array $context
 62      * @return null
 63      */
 64     public function error($message, array $context = array())
 65     {
 66         $this->log(LogLevel::ERROR, $message, $context);
 67     }
 68 
 69     /**
 70      * Exceptional occurrences that are not errors.
 71      *
 72      * Example: Use of deprecated APIs, poor use of an API, undesirable things
 73      * that are not necessarily wrong.
 74      *
 75      * @param string $message
 76      * @param array $context
 77      * @return null
 78      */
 79     public function warning($message, array $context = array())
 80     {
 81         $this->log(LogLevel::WARNING, $message, $context);
 82     }
 83 
 84     /**
 85      * Normal but significant events.
 86      *
 87      * @param string $message
 88      * @param array $context
 89      * @return null
 90      */
 91     public function notice($message, array $context = array())
 92     {
 93         $this->log(LogLevel::NOTICE, $message, $context);
 94     }
 95 
 96     /**
 97      * Interesting events.
 98      *
 99      * Example: User logs in, SQL logs.
100      *
101      * @param string $message
102      * @param array $context
103      * @return null
104      */
105     public function info($message, array $context = array())
106     {
107         $this->log(LogLevel::INFO, $message, $context);
108     }
109 
110     /**
111      * Detailed debug information.
112      *
113      * @param string $message
114      * @param array $context
115      * @return null
116      */
117     public function debug($message, array $context = array())
118     {
119         $this->log(LogLevel::DEBUG, $message, $context);
120     }
121 
122     /**
123      * Logs with an arbitrary level.
124      *
125      * @param mixed $level
126      * @param string $message
127      * @param array $context
128      * @return null
129      */
130     abstract public function log($level, $message, array $context = array());
131 }
132 
AloFramework Logger API documentation generated byApiGen 2.8.0