CodeIgniter v4.5 API

TestLogger extends Logger
in package

The CodeIgntier Logger

Tags
see
TestLoggerTest

Table of Contents

Properties

$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<class-string, array<string, int|array<int, string>|string>>
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  : array<int, array{level: mixed, message: string, file: string|null}>

Methods

__construct()  : mixed
Constructor.
alert()  : void
Action must be taken immediately.
cleanup()  : string
Expose filenames.
critical()  : void
Critical conditions.
debug()  : void
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()  : void
System is unusable.
error()  : void
Runtime errors that do not require immediate action but should typically be logged and monitored.
info()  : void
Interesting events.
log()  : void
The log method is overridden so that we can store log history during the tests to allow us to check ->assertLogged() methods.
notice()  : void
Normal but significant events.
warning()  : void
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()  : string
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<class-string, array<string, int|array<int, string>|string>> $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]

$op_logs

protected static array<int, array{level: mixed, message: string, file: string|null}> $op_logs = []

Methods

__construct()

Constructor.

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

alert()

Action must be taken immediately.

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

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> = []

cleanup()

Expose filenames.

public cleanup(string $file) : string

No longer needed as underlying protected method is also deprecated.

Parameters
$file : string
Return values
string

critical()

Critical conditions.

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

Example: Application component unavailable, unexpected exception.

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

debug()

Detailed debug information.

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

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 $useExactComparison = true ]) : bool
Parameters
$level : string
$message : string
$useExactComparison : bool = true
Return values
bool

emergency()

System is unusable.

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

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 = [] ]) : void
Parameters
$message : string
$context : array<string|int, mixed> = []

info()

Interesting events.

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

Example: User logs in, SQL logs.

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

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(mixed $level, string $message[, array<string|int, mixed> $context = [] ]) : void
Parameters
$level : mixed
$message : string
$context : array<string|int, mixed> = []

notice()

Normal but significant events.

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

warning()

Exceptional occurrences that are not errors.

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

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> = []

cleanFileNames()

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

protected cleanFileNames(string $file) : string

Use dedicated clean_path() function.

/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(string $message[, array<string|int, mixed> $context = [] ]) : string

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

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

        
On this page

Search results