SimpleLogger
extends AbstractLogger
Table of Contents
Constants
-
RFC5424_LEVELS
= [\Psr\Log\LogLevel::EMERGENCY => 0, \Psr\Log\LogLevel::ALERT => 1, \Psr\Log\LogLevel::CRITICAL => 2, \Psr\Log\LogLevel::ERROR => 3, \Psr\Log\LogLevel::WARNING => 4, \Psr\Log\LogLevel::NOTICE => 5, \Psr\Log\LogLevel::INFO => 6, \Psr\Log\LogLevel::DEBUG => 7]
Properties
-
$absoluteFilePath
: string
-
$logFormat
: string
-
$logLevel
: string
-
$logStore
: array<string|int, mixed>
-
$type
: LoggerType
Methods
-
__construct()
: mixed
-
log()
: void
-
logStore()
: string|array<string|int, mixed>
-
setLogFormat()
: void
-
createLine()
: string
-
formatException()
: string
-
formatObject()
: string
-
interpolate()
: string
-
isException()
: bool
-
validateLevel()
: void
-
writeLine()
: void
-
writeLineToFile()
: void
-
writeToErrorLog()
: void
RFC5424_LEVELS
public
mixed
RFC5424_LEVELS
= [\Psr\Log\LogLevel::EMERGENCY => 0, \Psr\Log\LogLevel::ALERT => 1, \Psr\Log\LogLevel::CRITICAL => 2, \Psr\Log\LogLevel::ERROR => 3, \Psr\Log\LogLevel::WARNING => 4, \Psr\Log\LogLevel::NOTICE => 5, \Psr\Log\LogLevel::INFO => 6, \Psr\Log\LogLevel::DEBUG => 7]
$absoluteFilePath
read-only
private
string
$absoluteFilePath
private
string
$logFormat
= '[{datetime}] [{level}] {message}'
$logLevel
read-only
private
string
$logLevel
$logStore
private
array<string|int, mixed>
$logStore
= []
$type
read-only
private
LoggerType
$type
__construct()
public
__construct([LoggerType $type = LoggerType::ERROR_LOG ][, string $logLevel = LogLevel::DEBUG ][, string $absoluteFilePath = '' ]) : mixed
Parameters
-
$type
: LoggerType
= LoggerType::ERROR_LOG
-
-
$logLevel
: string
= LogLevel::DEBUG
-
-
$absoluteFilePath
: string
= ''
-
log()
public
log(mixed $level, string|Stringable $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
-
$level
: mixed
-
-
$message
: string|Stringable
-
-
$context
: array<string|int, mixed>
= []
-
logStore()
public
logStore([bool $asString = true ]) : string|array<string|int, mixed>
Parameters
-
$asString
: bool
= true
-
Return values
string|array<string|int, mixed>
public
setLogFormat(string $logFormat) : void
Parameters
-
$logFormat
: string
-
createLine()
private
createLine(string $level, string $message) : string
Parameters
-
$level
: string
-
-
$message
: string
-
private
formatException(Throwable $exception) : string
Parameters
-
$exception
: Throwable
-
private
formatObject(object $object) : string
Parameters
-
$object
: object
-
interpolate()
private
interpolate(string $message, array<string|int, mixed> $context) : string
Parameters
-
$message
: string
-
-
$context
: array<string|int, mixed>
-
isException()
private
isException(string $key, mixed $exception) : bool
Parameters
-
$key
: string
-
-
$exception
: mixed
-
validateLevel()
private
validateLevel(string $level) : void
Parameters
-
$level
: string
-
writeLine()
private
writeLine(string $line) : void
Parameters
-
$line
: string
-
writeLineToFile()
private
writeLineToFile(string $line) : void
Parameters
-
$line
: string
-
writeToErrorLog()
private
writeToErrorLog(string $line) : void
Parameters
-
$line
: string
-