Overview

Namespaces

  • None
  • OpenCloud
    • Autoscale
      • Resource
    • CloudMonitoring
      • Exception
      • Resource
    • Common
      • Exceptions
      • Log
      • Request
        • Response
    • Compute
    • Database
    • DNS
    • LoadBalancer
      • Resources
    • ObjectStore
      • Resource
    • Orchestration
    • Volume
  • PHP

Classes

  • AbstractLogger
  • Logger
  • LogLevel

Interfaces

  • LoggerInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Download
  1: <?php
  2: 
  3: // Copyright (c) 2012 PHP Framework Interoperability Group
  4: //
  5: // Permission is hereby granted, free of charge, to any person obtaining a copy 
  6: // of this software and associated documentation files (the "Software"), to deal
  7: // in the Software without restriction, including without limitation the rights 
  8: // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
  9: // copies of the Software, and to permit persons to whom the Software is 
 10: // furnished to do so, subject to the following conditions:
 11: //
 12: // The above copyright notice and this permission notice shall be included in 
 13: // all copies or substantial portions of the Software.
 14: //
 15: // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16: // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17: // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18: // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19: // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 20: // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 21: // THE SOFTWARE.
 22: 
 23: namespace OpenCloud\Common\Log;
 24: 
 25: /**
 26:  * This is a simple Logger implementation that other Loggers can inherit from.
 27:  *
 28:  * It simply delegates all log-level-specific methods to the `log` method to
 29:  * reduce boilerplate code that a simple Logger that does the same thing with
 30:  * messages regardless of the error level has to implement.
 31:  */
 32: abstract class AbstractLogger implements LoggerInterface
 33: {
 34:     /**
 35:      * System is unusable.
 36:      *
 37:      * @param string $message
 38:      * @param array $context
 39:      * @return null
 40:      */
 41:     public function emergency($message, array $context = array())
 42:     {
 43:         $this->log(LogLevel::EMERGENCY, $message, $context);
 44:     }
 45: 
 46:     /**
 47:      * Action must be taken immediately.
 48:      *
 49:      * Example: Entire website down, database unavailable, etc. This should
 50:      * trigger the SMS alerts and wake you up.
 51:      *
 52:      * @param string $message
 53:      * @param array $context
 54:      * @return null
 55:      */
 56:     public function alert($message, array $context = array())
 57:     {
 58:         $this->log(LogLevel::ALERT, $message, $context);
 59:     }
 60: 
 61:     /**
 62:      * Critical conditions.
 63:      *
 64:      * Example: Application component unavailable, unexpected exception.
 65:      *
 66:      * @param string $message
 67:      * @param array $context
 68:      * @return null
 69:      */
 70:     public function critical($message, array $context = array())
 71:     {
 72:         $this->log(LogLevel::CRITICAL, $message, $context);
 73:     }
 74: 
 75:     /**
 76:      * Runtime errors that do not require immediate action but should typically
 77:      * be logged and monitored.
 78:      *
 79:      * @param string $message
 80:      * @param array $context
 81:      * @return null
 82:      */
 83:     public function error($message, array $context = array())
 84:     {
 85:         $this->log(LogLevel::ERROR, $message, $context);
 86:     }
 87: 
 88:     /**
 89:      * Exceptional occurrences that are not errors.
 90:      *
 91:      * Example: Use of deprecated APIs, poor use of an API, undesirable things
 92:      * that are not necessarily wrong.
 93:      *
 94:      * @param string $message
 95:      * @param array $context
 96:      * @return null
 97:      */
 98:     public function warning($message, array $context = array())
 99:     {
100:         $this->log(LogLevel::WARNING, $message, $context);
101:     }
102: 
103:     /**
104:      * Normal but significant events.
105:      *
106:      * @param string $message
107:      * @param array $context
108:      * @return null
109:      */
110:     public function notice($message, array $context = array())
111:     {
112:         $this->log(LogLevel::NOTICE, $message, $context);
113:     }
114: 
115:     /**
116:      * Interesting events.
117:      *
118:      * Example: User logs in, SQL logs.
119:      *
120:      * @param string $message
121:      * @param array $context
122:      * @return null
123:      */
124:     public function info($message, array $context = array())
125:     {
126:         $this->log(LogLevel::INFO, $message, $context);
127:     }
128: 
129:     /**
130:      * Detailed debug information.
131:      *
132:      * @param string $message
133:      * @param array $context
134:      * @return null
135:      */
136:     public function debug($message, array $context = array())
137:     {
138:         $this->log(LogLevel::DEBUG, $message, $context);
139:     }
140: }
PHP OpenCloud API API documentation generated by ApiGen 2.8.0