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

Class ColoredIndentedLogger

PSR-3 logger for adding colors and indentation on PHP CLI output.

Use tags and placeholder syntax to provide an easy way to color and indent PHP CLI output. PSR-3 compatibility allows graceful degradation when switching to another PSR-3 compliant logger. See README.md for more information.

Copyright (c) 2013 Geoffroy Aubry <geoffroy.aubry@free.fr> Licensed under the GNU Lesser General Public License v3 (LGPL version 3).

Psr\Log\AbstractLogger implements Psr\Log\LoggerInterface
Extended by GAubry\Logger\AbstractLogger
Extended by GAubry\Logger\ColoredIndentedLogger
Namespace: GAubry\Logger
Copyright: 2013 Geoffroy Aubry <geoffroy.aubry@free.fr>
License: http://www.gnu.org/licenses/lgpl.html
See: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md
Located at logger/src/GAubry/Logger/ColoredIndentedLogger.php
Methods summary
public
# __construct( array $aConfig = array() )

Constructor.

Constructor.

Parameters

$aConfig
array
$aConfig see self::$aDefaultConfig

Throws

Psr\Log\InvalidArgumentException
if calling this method with a level not defined in \Psr\Log\LogLevel

Overrides

GAubry\Logger\AbstractLogger::__construct()
private
# buildColorTags( )

Build full length color tags by adding prefix to user define colors.

Build full length color tags by adding prefix to user define colors.

See

GAubry\Logger\ColoredIndentedLogger::$aColorTags
'color_tag_prefix' key of ColoredIndentedLogger::$aDefaultConfig
private string
# processLeadingIndentationTags( string $sMessage )

Update indentation level according to leading indentation tags and remove them from the returned string.

Update indentation level according to leading indentation tags and remove them from the returned string.

Parameters

$sMessage
string
$sMessage

Returns

string
specified message without any leading indentation tag

See

GAubry\Logger\ColoredIndentedLogger::$iIndentationLevel
private string
# processTrailingIndentationTags( string $sMessage )

Update indentation level according to trailing indentation tags and remove them from the returned string.

Update indentation level according to trailing indentation tags and remove them from the returned string.

Parameters

$sMessage
string
$sMessage

Returns

string
specified message without any trailing indentation tag

See

GAubry\Logger\ColoredIndentedLogger::$iIndentationLevel
public null
# log( mixed $sMsgLevel, string $sMessage, array $aContext = array() )

Logs with an arbitrary level.

Logs with an arbitrary level.

Allows adjustment of the indentation whith multiple leading or trailing tags: see $this->sIndentTag and $this->sUnindentTag

Allows insertion of bash colors via placeholders and context array.

Parameters

$sMsgLevel
mixed
$sMsgLevel message level, must be defined in \Psr\Log\LogLevel
$sMessage
string
$sMessage message with placeholders
$aContext
array
$aContext context array

Returns

null

Throws

Psr\Log\InvalidArgumentException
if calling this method with a level not defined in \Psr\Log\LogLevel
Methods inherited from GAubry\Logger\AbstractLogger
checkMsgLevel(), interpolateContext()
Methods inherited from Psr\Log\AbstractLogger
alert(), critical(), debug(), emergency(), error(), info(), notice(), warning()
Properties summary
private integer $iIndentTagLength
#

Length of the indent tag.

Length of the indent tag.

See

'indent_tag' key of ColoredIndentedLogger::$aDefaultConfig
private integer $iUnindentTagLength
#

Length of the unindent tag.

Length of the unindent tag.

See

'unindent_tag' key of ColoredIndentedLogger::$aDefaultConfig
private integer $iIndentationLevel
#

Current zero-based indentation level.

Current zero-based indentation level.

private array $aColorTags
#

Full length color tags combining prefix to user define colors.

Full length color tags combining prefix to user define colors.

See

GAubry\Logger\ColoredIndentedLogger::buildColorTags()
'color_tag_prefix' key of ColoredIndentedLogger::$aDefaultConfig
private static array $aDefaultConfig array( 'colors' => array(), 'base_indentation' => "\033[0;30m┆\033[0m ", 'indent_tag' => '+++', 'unindent_tag' => '---', 'min_message_level' => LogLevel::DEBUG, 'reset_color_sequence' => "\033[0m", 'color_tag_prefix' => 'C.' )
#

Default configuration.
– 'colors' => (array) Array of key/value pairs to associate bash color codes to color tags.
Example: array(
'debug' => "\033[0;30m",
'warning' => "\033[0;33m",
'error' => "\033[1;31m"
)
– 'base_indentation' => (string) Describe what is a simple indentation, e.g. "\t".
– 'indent_tag' => (string) Tag usable at the start or at the end of the message to add
one or more indentation level.
– 'unindent_tag' => (string) Tag usable at the start or at the end of the message to remove
one or more indentation level.
– 'min_message_level' => (string) Threshold required to log message, must be defined in \Psr\Log\LogLevel.
– 'reset_color_sequence' => (string) Concatenated sequence at the end of message when colors are used.
For example: "\033[0m".
– 'color_tag_prefix' => (string) Prefix used in placeholders to distinguish standard context from colors.

Default configuration. – 'colors' => (array) Array of key/value pairs to associate bash color codes to color tags. Example: array( 'debug' => "\033[0;30m", 'warning' => "\033[0;33m", 'error' => "\033[1;31m" ) – 'base_indentation' => (string) Describe what is a simple indentation, e.g. "\t". – 'indent_tag' => (string) Tag usable at the start or at the end of the message to add one or more indentation level. – 'unindent_tag' => (string) Tag usable at the start or at the end of the message to remove one or more indentation level. – 'min_message_level' => (string) Threshold required to log message, must be defined in \Psr\Log\LogLevel. – 'reset_color_sequence' => (string) Concatenated sequence at the end of message when colors are used. For example: "\033[0m". – 'color_tag_prefix' => (string) Prefix used in placeholders to distinguish standard context from colors.

private array $aConfig
#

Current configuration.

Current configuration.

See

GAubry\Logger\ColoredIndentedLogger::$aDefaultConfig
Properties inherited from GAubry\Logger\AbstractLogger
$aIntLevels, $iMinMsgLevel
Platform for Automatized Deployments with pOwerful Concise Configuration API documentation generated by ApiGen 2.8.0