\CodeIgniter\LogLogger

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".

Summary

Methods
Properties
Constants
__construct()
emergency()
alert()
critical()
error()
warning()
notice()
info()
debug()
log()
determineFile()
$logCache
No constants found
interpolate()
cleanFileNames()
$logPath
$logLevels
$loggableLevels
$filePermissions
$dateFormat
$fileExt
$handlers
$handlerConfig
$cacheLogs
N/A
No private methods found
No private properties found
N/A

Properties

$logCache

$logCache : array

Caches logging calls for debugbar.

Type

array

$logPath

$logPath : string

Path to save log files to.

Type

string

$logLevels

$logLevels : array

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

Type

array

$loggableLevels

$loggableLevels : array

Array of levels to be logged.

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

Type

array

$filePermissions

$filePermissions : integer

File permissions

Type

integer

$dateFormat

$dateFormat : string

Format of the timestamp for log files.

Type

string

$fileExt

$fileExt : string

Filename Extension

Type

string

$handlers

$handlers : array

Caches instances of the handlers.

Type

array

$handlerConfig

$handlerConfig : array

Holds the configuration for each handler.

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

Type

array

$cacheLogs

$cacheLogs : boolean

Should we cache our logged items?

Type

boolean

Methods

__construct()

__construct(\Config\Logger  $config, boolean  $debug = CI_DEBUG) 

Constructor.

Parameters

\Config\Logger $config
boolean $debug

Throws

\RuntimeException

emergency()

emergency(string  $message, array  $context = array()) : boolean

System is unusable.

Parameters

string $message
array $context

Returns

boolean

alert()

alert(string  $message, array  $context = array()) : boolean

Action must be taken immediately.

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

Parameters

string $message
array $context

Returns

boolean

critical()

critical(string  $message, array  $context = array()) : boolean

Critical conditions.

Example: Application component unavailable, unexpected exception.

Parameters

string $message
array $context

Returns

boolean

error()

error(string  $message, array  $context = array()) : boolean

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

Parameters

string $message
array $context

Returns

boolean

warning()

warning(string  $message, array  $context = array()) : boolean

Exceptional occurrences that are not errors.

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

Parameters

string $message
array $context

Returns

boolean

notice()

notice(string  $message, array  $context = array()) : boolean

Normal but significant events.

Parameters

string $message
array $context

Returns

boolean

info()

info(string  $message, array  $context = array()) : boolean

Interesting events.

Example: User logs in, SQL logs.

Parameters

string $message
array $context

Returns

boolean

debug()

debug(string  $message, array  $context = array()) : boolean

Detailed debug information.

Parameters

string $message
array $context

Returns

boolean

log()

log(mixed  $level, string  $message, array  $context = array()) : boolean

Logs with an arbitrary level.

Parameters

mixed $level
string $message
array $context

Returns

boolean

determineFile()

determineFile() : array

Determines the current file/line that the log method was called from.

by analyzing the backtrace.

Returns

array

interpolate()

interpolate(mixed  $message, array  $context = array()) : mixed

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

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

Parameters

mixed $message
array $context

Returns

mixed

cleanFileNames()

cleanFileNames(  $file) : string

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

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

Parameters

$file

Returns

string