balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

WPImporterLogger.php (3410B)


      1 <?php
      2 namespace ProteusThemes\WPContentImporter2;
      3 
      4 /**
      5  * Describes a logger instance
      6  *
      7  * Based on PSR-3: http://www.php-fig.org/psr/psr-3/
      8  *
      9  * The message MUST be a string or object implementing __toString().
     10  *
     11  * The message MAY contain placeholders in the form: {foo} where foo
     12  * will be replaced by the context data in key "foo".
     13  *
     14  * The context array can contain arbitrary data, the only assumption that
     15  * can be made by implementors is that if an Exception instance is given
     16  * to produce a stack trace, it MUST be in a key named "exception".
     17  *
     18  * See https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
     19  * for the full interface specification.
     20  */
     21 class WPImporterLogger {
     22 	/**
     23 	 * System is unusable.
     24 	 *
     25 	 * @param string $message
     26 	 * @param array $context
     27 	 * @return null
     28 	 */
     29 	public function emergency( $message, array $context = array() ) {
     30 		return $this->log( 'emergency', $message, $context );
     31 	}
     32 
     33 	/**
     34 	 * Action must be taken immediately.
     35 	 *
     36 	 * Example: Entire website down, database unavailable, etc. This should
     37 	 * trigger the SMS alerts and wake you up.
     38 	 *
     39 	 * @param string $message
     40 	 * @param array $context
     41 	 * @return null
     42 	 */
     43 	public function alert( $message, array $context = array() ) {
     44 		return $this->log( 'alert', $message, $context );
     45 	}
     46 
     47 	/**
     48 	 * Critical conditions.
     49 	 *
     50 	 * Example: Application component unavailable, unexpected exception.
     51 	 *
     52 	 * @param string $message
     53 	 * @param array $context
     54 	 * @return null
     55 	 */
     56 	public function critical( $message, array $context = array() ) {
     57 		return $this->log( 'critical', $message, $context );
     58 	}
     59 
     60 	/**
     61 	 * Runtime errors that do not require immediate action but should typically
     62 	 * be logged and monitored.
     63 	 *
     64 	 * @param string $message
     65 	 * @param array $context
     66 	 * @return null
     67 	 */
     68 	public function error( $message, array $context = array()) {
     69 		return $this->log( 'error', $message, $context );
     70 	}
     71 
     72 	/**
     73 	 * Exceptional occurrences that are not errors.
     74 	 *
     75 	 * Example: Use of deprecated APIs, poor use of an API, undesirable things
     76 	 * that are not necessarily wrong.
     77 	 *
     78 	 * @param string $message
     79 	 * @param array $context
     80 	 * @return null
     81 	 */
     82 	public function warning( $message, array $context = array() ) {
     83 		return $this->log( 'warning', $message, $context );
     84 	}
     85 
     86 	/**
     87 	 * Normal but significant events.
     88 	 *
     89 	 * @param string $message
     90 	 * @param array $context
     91 	 * @return null
     92 	 */
     93 	public function notice( $message, array $context = array() ) {
     94 		return $this->log( 'notice', $message, $context );
     95 	}
     96 
     97 	/**
     98 	 * Interesting events.
     99 	 *
    100 	 * Example: User logs in, SQL logs.
    101 	 *
    102 	 * @param string $message
    103 	 * @param array $context
    104 	 * @return null
    105 	 */
    106 	public function info( $message, array $context = array() ) {
    107 		return $this->log( '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 		return $this->log( 'debug', $message, $context );
    119 	}
    120 
    121 	/**
    122 	 * Logs with an arbitrary level.
    123 	 *
    124 	 * @param mixed $level
    125 	 * @param string $message
    126 	 * @param array $context
    127 	 * @return null
    128 	 */
    129 	public function log( $level, $message, array $context = array() ) {
    130 		$this->messages[] = array(
    131 			'timestamp' => time(),
    132 			'level'     => $level,
    133 			'message'   => $message,
    134 			'context'   => $context,
    135 		);
    136 	}
    137 }