Documentation

TestLogger extends Logger
in package

The CodeIgntier Logger

The message MUST be a string or object implementing __toString().

The message MAY contain placeholders in the form: {foo} where foo will be replaced by the context data in key "foo".

The context array can contain arbitrary data, the only assumption that can be made by implementors is that if an Exception instance is given to produce a stack trace, it MUST be in a key named "exception".

Table of Contents

$logCache  : array<string|int, mixed>
Caches logging calls for debugbar.
$cacheLogs  : bool
Should we cache our logged items?
$dateFormat  : string
Format of the timestamp for log files.
$fileExt  : string
Filename Extension
$filePermissions  : int
File permissions
$handlerConfig  : array<string|int, mixed>
Holds the configuration for each handler.
$handlers  : array<string|int, mixed>
Caches instances of the handlers.
$loggableLevels  : array<string|int, mixed>
Array of levels to be logged.
$logLevels  : array<string, int>
Used by the logThreshold Config setting to define which errors to show.
$op_logs  : mixed
__construct()  : mixed
Constructor.
alert()  : bool
Action must be taken immediately.
cleanup()  : mixed
critical()  : bool
Critical conditions.
debug()  : bool
Detailed debug information.
determineFile()  : array<string|int, mixed>
Determines the file and line that the logging call was made from by analyzing the backtrace.
didLog()  : bool
Used by CIUnitTestCase class to provide ->assertLogged() methods.
emergency()  : bool
System is unusable.
error()  : bool
Runtime errors that do not require immediate action but should typically be logged and monitored.
info()  : bool
Interesting events.
log()  : bool
The log method is overridden so that we can store log history during the tests to allow us to check ->assertLogged() methods.
notice()  : bool
Normal but significant events.
warning()  : bool
Exceptional occurrences that are not errors.
cleanFileNames()  : string
Cleans the paths of filenames by replacing APPPATH, SYSTEMPATH, FCPATH with the actual var. i.e.
interpolate()  : mixed
Replaces any placeholders in the message with variables from the context, as well as a few special items like:

Properties

$logCache

Caches logging calls for debugbar.

public array<string|int, mixed> $logCache

$cacheLogs

Should we cache our logged items?

protected bool $cacheLogs = false

$dateFormat

Format of the timestamp for log files.

protected string $dateFormat = 'Y-m-d H:i:s'

$fileExt

Filename Extension

protected string $fileExt

$filePermissions

File permissions

protected int $filePermissions = 0644

$handlerConfig

Holds the configuration for each handler.

protected array<string|int, mixed> $handlerConfig = []

The key is the handler's class name. The value is an associative array of configuration items.

$handlers

Caches instances of the handlers.

protected array<string|int, mixed> $handlers = []

$loggableLevels

Array of levels to be logged.

protected array<string|int, mixed> $loggableLevels = []

The rest will be ignored. Set in Config/logger.php

$logLevels

Used by the logThreshold Config setting to define which errors to show.

protected array<string, int> $logLevels = ['emergency' => 1, 'alert' => 2, 'critical' => 3, 'error' => 4, 'warning' => 5, 'notice' => 6, 'info' => 7, 'debug' => 8]

Methods

__construct()

Constructor.

public __construct(Logger $config[, bool $debug = CI_DEBUG ]) : mixed
Parameters
$config : Logger
$debug : bool = CI_DEBUG
Tags
throws
RuntimeException
Return values
mixed

alert()

Action must be taken immediately.

public alert(string $message[, array<string|int, mixed> $context = [] ]) : bool

Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.

Parameters
$message : string
$context : array<string|int, mixed> = []
Return values
bool

cleanup()

public cleanup(mixed $file) : mixed
Parameters
$file : mixed
Return values
mixed

critical()

Critical conditions.

public critical(string $message[, array<string|int, mixed> $context = [] ]) : bool

Example: Application component unavailable, unexpected exception.

Parameters
$message : string
$context : array<string|int, mixed> = []
Return values
bool

debug()

Detailed debug information.

public debug(string $message[, array<string|int, mixed> $context = [] ]) : bool
Parameters
$message : string
$context : array<string|int, mixed> = []
Return values
bool

determineFile()

Determines the file and line that the logging call was made from by analyzing the backtrace.

public determineFile() : array<string|int, mixed>

Find the earliest stack frame that is part of our logging system.

Return values
array<string|int, mixed>

didLog()

Used by CIUnitTestCase class to provide ->assertLogged() methods.

public static didLog(string $level, string $message) : bool
Parameters
$level : string
$message : string
Return values
bool

emergency()

System is unusable.

public emergency(string $message[, array<string|int, mixed> $context = [] ]) : bool
Parameters
$message : string
$context : array<string|int, mixed> = []
Return values
bool

error()

Runtime errors that do not require immediate action but should typically be logged and monitored.

public error(string $message[, array<string|int, mixed> $context = [] ]) : bool
Parameters
$message : string
$context : array<string|int, mixed> = []
Return values
bool

info()

Interesting events.

public info(string $message[, array<string|int, mixed> $context = [] ]) : bool

Example: User logs in, SQL logs.

Parameters
$message : string
$context : array<string|int, mixed> = []
Return values
bool

log()

The log method is overridden so that we can store log history during the tests to allow us to check ->assertLogged() methods.

public log(string $level, string $message[, array<string|int, mixed> $context = [] ]) : bool
Parameters
$level : string
$message : string
$context : array<string|int, mixed> = []
Return values
bool

notice()

Normal but significant events.

public notice(string $message[, array<string|int, mixed> $context = [] ]) : bool
Parameters
$message : string
$context : array<string|int, mixed> = []
Return values
bool

warning()

Exceptional occurrences that are not errors.

public warning(string $message[, array<string|int, mixed> $context = [] ]) : bool

Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.

Parameters
$message : string
$context : array<string|int, mixed> = []
Return values
bool

cleanFileNames()

Cleans the paths of filenames by replacing APPPATH, SYSTEMPATH, FCPATH with the actual var. i.e.

protected cleanFileNames(string $file) : string

/var/www/site/app/Controllers/Home.php becomes: APPPATH/Controllers/Home.php

Parameters
$file : string
Return values
string

interpolate()

Replaces any placeholders in the message with variables from the context, as well as a few special items like:

protected interpolate(mixed $message[, array<string|int, mixed> $context = [] ]) : mixed

{session_vars} {post_vars} {get_vars} {env} {env:foo} {file} {line}

Parameters
$message : mixed
$context : array<string|int, mixed> = []
Return values
mixed

Search results