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