Overview

Namespaces

  • AloFramework
    • Log
  • PHP
  • Psr
    • Log
      • Test

Classes

  • Log

Exceptions

  • LogException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo

Class Log

AloFramework logger

Psr\Log\LogLevel
Extended by AloFramework\Log\Log implements Psr\Log\LoggerInterface uses Psr\Log\LoggerTrait
Namespace: AloFramework\Log
Author: Art a.molcanovas@gmail.com
Located at class/Log.php
Methods summary
public
# __construct( string $logLevel = Psr\Log\LogLevel::DEBUG, string $label = ALO_LOG_LABEL, string $savePath = ALO_LOG_SAVE_PATH )

Constructor

Constructor

Parameters

$logLevel
Minimum log level to log. See class constants.
$label
Log label, e.g. if you specify 'System' log entries will be prepended with SYSTEM
$savePath

The file to save the logs in. If omitted, the logs directory in this package will be used with the filenames being today's date in YYYY-mm-dd format.

Throws

AloFramework\Log\LogException
When a save path is specified, but the directory does not exist
InvalidArgumentException
When $log isn't scalar or $logLevel is invalid

Author

Art a.molcanovas@gmail.com
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 AloFramework\Log\Log|string
# savePath( string|null $path = null )

Gets or sets the log file path

Gets or sets the log file path

Parameters

$path
Omit if using as a getter; The path to the log file otherwise

Returns

AloFramework\Log\Log|string

Throws

AloFramework\Log\LogException
When the directory doesn't exist
InvalidArgumentException
When the path isn't a valid string

Author

Art a.molcanovas@gmail.com
public AloFramework\Log\Log|string
# logLabel( string|null $set = null )

Gets or sets the log label

Gets or sets the log label

Parameters

$set
Omit if using as a getter, the new log label if using as a setter.

Returns

AloFramework\Log\Log|string

Throws

InvalidArgumentException
If attempting to set an invalid log level

Author

Art a.molcanovas@gmail.com
public AloFramework\Log\Log|string
# level( string|null $set = null )

Gets or sets the log level

Gets or sets the log level

Parameters

$set

Omit if using as a getter, the log level if using as a setter - see class constants or refer to the PSR-3 standards.

Returns

AloFramework\Log\Log|string

Throws

InvalidArgumentException
If attempting to set an invalid log level

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

InvalidArgumentException
When the log level is invalid

Implementation of

Psr\Log\LoggerInterface::log()
private boolean
# doWrite( string $level, string $message )

Performs the actual log operation

Performs the actual log operation

Parameters

$level
Log level
$message
Raw message

Returns

boolean

Author

Art a.molcanovas@gmail.com
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
Methods inherited from Psr\Log\LoggerInterface
alert(), critical(), debug(), emergency(), error(), info(), notice(), warning()
Methods used from Psr\Log\LoggerTrait
alert(), critical(), debug(), emergency(), error(), info(), notice(), warning()
Constants inherited from Psr\Log\LogLevel
ALERT, CRITICAL, DEBUG, EMERGENCY, ERROR, INFO, NOTICE, WARNING
Properties summary
protected string $label

Log identifier

Log identifier

#
protected string $savePath

Where the logs are stored

Where the logs are stored

#
protected string $level

Log level set

Log level set

#
private static string $SEPARATOR

Log element separator

Log element separator

# '|'
private static array $priority

Log levels and their priorities

Log levels and their priorities

# [self::DEBUG => 1, self::INFO => 2, self::NOTICE => 3, self::WARNING => 4, self::ERROR => 5, self::CRITICAL => 6, self::ALERT => 7, self::EMERGENCY => 8]
AloFramework Logger API documentation generated by ApiGen