AloFramework Logger 2.1 API
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Namespaces

  • AloFramework
    • Log
  • PHP

Classes

  • Config
  • InvalidArgumentException
  • Log

Class Log

AloFramework logger.

Psr\Log\LogLevel
Extended by AloFramework\Log\Log implements Psr\Log\LoggerInterface, AloFramework\Config\Configurable uses Psr\Log\LoggerTrait (not available) AloFramework\Config\ConfigurableTrait (not available)
Namespace: AloFramework\Log
Author: Art a.molcanovas@gmail.com
Since:

2.0 Is now configured via the Configurable interface
1.4 buildMessage() added
1.3 getBacktrace(), self::$ignoredFiles added
1.2 time() added, the separator is now a constant
1.1 getLastMessage() added


Located at class/Log.php

Methods summary

public
# __construct( AloFramework\Log\Config $cfg = null )

Constructor.

Constructor.

Parameters

$cfg
The configuration object

Throws

AloFramework\Log\InvalidArgumentException
When $log isn't scalar or $logLevel is invalid

Author

Art a.molcanovas@gmail.com
public
# __destruct( )

Cleanup operations

Cleanup operations

Author

Art a.molcanovas@gmail.com
public static array
# getPriority( )

Returns the log level priority

Returns the log level priority

Returns

array

Author

Art a.molcanovas@gmail.com
public string
# getLastMessage( boolean $full = false )

Returns the last logged message

Returns the last logged message

Parameters

$full
If set to true, will return the message as it appears in the log

Returns

string

Author

Art a.molcanovas@gmail.com

Since

2.0 $full added
1.1


public string
# __toString( )

Returns a string representation of the class.

Returns a string representation of the class.

Returns

string

Author

Art a.molcanovas@gmail.com
public boolean
# log( string $level, string $message, array $context = [] )

Logs with an arbitrary level.

Logs with an arbitrary level.

Parameters

$level
The message's log level
$message
The message
$context
The message context/placeholder asociative array

Returns

boolean
Whether the message has been written

Throws

AloFramework\Log\InvalidArgumentException
When the log level is invalid
protected array
# getBacktrace( )

Returns the debug backtrace

Returns the debug backtrace

Returns

array

Author

Art a.molcanovas@gmail.com

Since

1.3
protected string
# buildMessage( string $level, string $text )

Builds the message as it will appear in the log file

Builds the message as it will appear in the log file

Parameters

$level
Message level
$text
User-supplied message text

Returns

string
The built message

Author

Art a.molcanovas@gmail.com

Since

1.4
protected string
# time( )

Returns the current time for log messages. Added as a method so you can overwrite it to the format you want

Returns the current time for log messages. Added as a method so you can overwrite it to the format you want

Returns

string

Author

Art a.molcanovas@gmail.com

Since

1.2
protected static string
# replaceContext( string $message, array $context = [] )

Replaces the placeholders in the message.

Replaces the placeholders in the message.

Parameters

$message
The raw message
$context
The context/placeholder assoc array

Returns

string

Constants summary

string SEPARATOR

Log element separator.

Log element separator.

Since

1.2 is a constant, not private static
# '|'

Properties summary

protected static array $ignoredFiles

File name fragments to ignore when generating the backtrace

File name fragments to ignore when generating the backtrace

Since

1.3
# ['Log.php']

Magic properties

public AloFramework\Log\Config $config

Configuration object

AloFramework Logger 2.1 API API documentation generated by ApiGen