Overview

Namespaces

  • GAubry
    • ErrorHandler
    • Helpers
    • Logger
    • Shell
  • Himedia
    • Padocc
      • DB
      • Minifier
      • Numbering
      • Properties
      • Task
        • Base
        • Extended
  • None
  • Psr
    • Log

Classes

  • AbstractLogger
  • ColoredIndentedLogger
  • MinimalLogger
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
 1: <?php
 2: 
 3: namespace GAubry\Logger;
 4: 
 5: use Psr\Log\LogLevel;
 6: 
 7: /**
 8:  * This Logger can be used to avoid both indentation and insertion of bash color codes into log messages.
 9:  *
10:  * Logging should always be optional, and if no logger is provided to your
11:  * library creating a \Psr\Log\NullLogger instance in order to avoid conditional log calls.
12:  *
13:  * Copyright (c) 2013 Geoffroy Aubry <geoffroy.aubry@free.fr>
14:  * Licensed under the GNU Lesser General Public License v3 (LGPL version 3).
15:  *
16:  * @copyright 2013 Geoffroy Aubry <geoffroy.aubry@free.fr>
17:  * @license http://www.gnu.org/licenses/lgpl.html
18:  */
19: class MinimalLogger extends AbstractLogger
20: {
21:     /**
22:      * Constructor.
23:      *
24:      * @param string $iMinMsgLevel threshold required to log message, must be defined in \Psr\Log\LogLevel
25:      * @throws \Psr\Log\InvalidArgumentException if calling this method with a level not defined in \Psr\Log\LogLevel
26:      */
27:     public function __construct ($sMinMsgLevel = LogLevel::DEBUG)
28:     {
29:         parent::__construct($sMinMsgLevel);
30:     }
31: 
32:     /**
33:      * Logs with an arbitrary level.
34:      *
35:      * @param string $sMsgLevel message level, must be defined in \Psr\Log\LogLevel
36:      * @param string $sMessage message with placeholders
37:      * @param array $aContext context array
38:      * @throws \Psr\Log\InvalidArgumentException if calling this method with a level not defined in \Psr\Log\LogLevel
39:      */
40:     public function log ($sMsgLevel, $sMessage, array $aContext = array())
41:     {
42:         $this->checkMsgLevel($sMsgLevel);
43:         if (self::$aIntLevels[$sMsgLevel] >= $this->iMinMsgLevel) {
44:             echo $this->interpolateContext($sMessage, $aContext) . PHP_EOL;
45:         }
46:     }
47: }
48: 
Platform for Automatized Deployments with pOwerful Concise Configuration API documentation generated by ApiGen 2.8.0