Logger\AbstractLogger
AbstractSource on GitHubAbstract Logger Class
Abstract logger class, providing common functionality. A formatter interface is available as well as an adapter one. Adapters can be created easily using the built in AdapterFactory. A LoggerFactory is also available that allows developers to create new instances of the Logger or load them from config files (see Phalcon\Config\Config object).
@property AdapterInterface[] $adapters @property array $excluded @property int $logLevel @property string $name @property string $timezone
Phalcon\Logger\AbstractLogger
Uses DateTimeImmutable · DateTimeZone · Exception · Phalcon\Logger\Adapter\AdapterInterface · Phalcon\Logger\Exceptions\AdapterNotFound · Phalcon\Logger\Exceptions\NoAdaptersConfigured
Method Summary
public__construct(string$name,array$adapters = [],DateTimeZone$timezone = null)Constructor.publicstaticaddAdapter(string$name,AdapterInterface$adapter)Add an adapter to the stack. For processing we use FIFOpublicstaticexcludeAdapters( array$adapters = [] )Exclude certain adapters.publicAdapterInterfacegetAdapter( string$name )Returns an adapter from the stackpublicarraygetAdapters()Returns the adapter stack arraypublicintgetLogLevel()Returns the log levelpublicstringgetName()Returns the name of the loggerpublicstaticremoveAdapter( string$name )Removes an adapter from the stackpublicstaticsetAdapters( array$adapters )Sets the adapters stack overriding what is already therepublicstaticsetLogLevel( int$level )Sets the adapters stack overriding what is already thereprotectedbooladdMessage(int$level,string$message,array$context = [])Adds a message to each handler for processingprotectedintgetLevelNumber( mixed$level )Converts the level from string/word to an integerprotectedarraygetLevels()Returns an array of log levels with integer to string conversionConstants
intALERT = 2intCRITICAL = 1intCUSTOM = 8intDEBUG = 7intEMERGENCY = 0intERROR = 3intINFO = 6intNOTICE = 5intTRACE = 9intWARNING = 4Properties
protectedAdapterInterface[]$adapters = []The adapter stackprotectedarray$excluded = []The excluded adapters for this log processprotectedint$logLevel = 8Minimum log level for the loggerprotectedstring$name = ""protectedDateTimeZone$timezoneMethods
__construct()
public function __construct(
string $name,
array $adapters = [],
DateTimeZone $timezone = null
);Constructor.
addAdapter()
public function addAdapter(
string $name,
AdapterInterface $adapter
): static;Add an adapter to the stack. For processing we use FIFO
excludeAdapters()
public function excludeAdapters( array $adapters = [] ): static;Exclude certain adapters.
getAdapter()
public function getAdapter( string $name ): AdapterInterface;Returns an adapter from the stack
getAdapters()
public function getAdapters(): array;Returns the adapter stack array
getLogLevel()
public function getLogLevel(): int;Returns the log level
getName()
public function getName(): string;Returns the name of the logger
removeAdapter()
public function removeAdapter( string $name ): static;Removes an adapter from the stack
setAdapters()
public function setAdapters( array $adapters ): static;Sets the adapters stack overriding what is already there
setLogLevel()
public function setLogLevel( int $level ): static;Sets the adapters stack overriding what is already there
addMessage()
protected function addMessage(
int $level,
string $message,
array $context = []
): bool;Adds a message to each handler for processing
getLevelNumber()
protected function getLevelNumber( mixed $level ): int;Converts the level from string/word to an integer
getLevels()
protected function getLevels(): array;Returns an array of log levels with integer to string conversion
Logger\AdapterFactory
ClassSource on GitHubFactory used to create adapters used for Logging
Phalcon\Factory\AbstractConfigFactoryPhalcon\Factory\AbstractFactoryPhalcon\Logger\AdapterFactory
Uses Phalcon\Factory\AbstractFactory · Phalcon\Logger\Adapter\AdapterInterface · Phalcon\Logger\Exception
Method Summary
public__construct( array$services = [] )AdapterFactory constructor.publicAdapterInterfacenewInstance(string$name,string$fileName,array$options = [])Create a new instance of the adapterprotectedstringgetExceptionClass()protectedarraygetServices()Returns the available adaptersMethods
__construct()
public function __construct( array $services = [] );AdapterFactory constructor.
newInstance()
public function newInstance(
string $name,
string $fileName,
array $options = []
): AdapterInterface;Create a new instance of the adapter
getExceptionClass()
protected function getExceptionClass(): string;getServices()
protected function getServices(): array;Returns the available adapters
Logger\Adapter\AbstractAdapter
AbstractSource on GitHubClass AbstractAdapter
@property string $defaultFormatter @property FormatterInterface $formatter @property bool $inTransaction @property array $queue
Phalcon\Logger\Adapter\AbstractAdapter— implementsPhalcon\Logger\Adapter\AdapterInterface
Uses Phalcon\Logger\Exceptions\DeserializationFailed · Phalcon\Logger\Exceptions\SerializationFailed · Phalcon\Logger\Exceptions\TransactionAlreadyActive · Phalcon\Logger\Exceptions\TransactionNotActive · Phalcon\Logger\Formatter\FormatterInterface · Phalcon\Logger\Formatter\Line · Phalcon\Logger\Item
Method Summary
public__destruct()Destructor cleanuppublicarray__serialize()Prevent serializationpublicvoid__unserialize( array$data )Prevent unserializationpublicAdapterInterfaceadd( Item$item )Adds a message to the queuepublicAdapterInterfacebegin()Starts a transactionpublicAdapterInterfacecommit()Commits the internal transactionpublicFormatterInterfacegetFormatter()publicintgetQueueLimit()Returns the configured transaction-queue cap (0 = unlimited)publicboolinTransaction()Returns the whether the logger is currently in an active transaction orpublicvoidprocess( Item$item )Processes the message in the adapterpublicAdapterInterfacerollback()Rollbacks the internal transactionpublicAdapterInterfacesetFormatter( FormatterInterface$formatter )Sets the message formatterpublicAdapterInterfacesetQueueLimit( int$queueLimit )Sets the maximum number of items retained in the transactionprotectedstringgetFormattedItem( Item$item )Returns the formatted itemProperties
protectedstring$defaultFormatter = "Phalcon\Logger\Formatter\Line"Name of the default formatter classprotectedFormatterInterface|null$formatter = nullFormatterprotectedbool$inTransaction = falseTells if there is an active transaction or notprotectedarray$queue = []Array with messages queued in the transactionprotectedint$queueLimit = 0Maximum number of items retained in the transaction queue. 0 (default) keeps the original unbounded behavior; a positive value drops the oldest queued item FIFO before a new one is appended in add().Methods
__destruct()
public function __destruct();Destructor cleanup
__serialize()
public function __serialize(): array;Prevent serialization
__unserialize()
public function __unserialize( array $data ): void;Prevent unserialization
add()
public function add( Item $item ): AdapterInterface;Adds a message to the queue
begin()
public function begin(): AdapterInterface;Starts a transaction
commit()
public function commit(): AdapterInterface;Commits the internal transaction
getFormatter()
public function getFormatter(): FormatterInterface;getQueueLimit()
public function getQueueLimit(): int;Returns the configured transaction-queue cap (0 = unlimited)
inTransaction()
public function inTransaction(): bool;Returns the whether the logger is currently in an active transaction or not
process()
abstract public function process( Item $item ): void;Processes the message in the adapter
rollback()
public function rollback(): AdapterInterface;Rollbacks the internal transaction
setFormatter()
public function setFormatter( FormatterInterface $formatter ): AdapterInterface;Sets the message formatter
setQueueLimit()
public function setQueueLimit( int $queueLimit ): AdapterInterface;Sets the maximum number of items retained in the transaction queue. 0 disables the cap (the default; preserves the original unbounded behavior).
getFormattedItem()
protected function getFormattedItem( Item $item ): string;Returns the formatted item
Logger\Adapter\AdapterInterface
InterfaceSource on GitHubPhalcon\Logger\AdapterInterface
Interface for Phalcon\Logger adapters
Phalcon\Logger\Adapter\AdapterInterface
Uses Phalcon\Logger\Formatter\FormatterInterface · Phalcon\Logger\Item
Method Summary
publicAdapterInterfaceadd( Item$item )Adds a message in the queuepublicAdapterInterfacebegin()Starts a transactionpublicboolclose()Closes the loggerpublicAdapterInterfacecommit()Commits the internal transactionpublicFormatterInterfacegetFormatter()Returns the internal formatterpublicboolinTransaction()Returns the whether the logger is currently in an active transaction orpublicvoidprocess( Item$item )Processes the message in the adapterpublicAdapterInterfacerollback()Rollbacks the internal transactionpublicAdapterInterfacesetFormatter( FormatterInterface$formatter )Sets the message formatterMethods
add()
public function add( Item $item ): AdapterInterface;Adds a message in the queue
begin()
public function begin(): AdapterInterface;Starts a transaction
close()
public function close(): bool;Closes the logger
commit()
public function commit(): AdapterInterface;Commits the internal transaction
getFormatter()
public function getFormatter(): FormatterInterface;Returns the internal formatter
inTransaction()
public function inTransaction(): bool;Returns the whether the logger is currently in an active transaction or not
process()
public function process( Item $item ): void;Processes the message in the adapter
rollback()
public function rollback(): AdapterInterface;Rollbacks the internal transaction
setFormatter()
public function setFormatter( FormatterInterface $formatter ): AdapterInterface;Sets the message formatter
Logger\Adapter\Exceptions\FileOpenFailed
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Logger\ExceptionPhalcon\Logger\Adapter\Exceptions\FileOpenFailed
Uses Phalcon\Logger\Exception
Method Summary
Methods
__construct()
public function __construct(
string $name,
string $mode
);Logger\Adapter\Exceptions\InvalidStreamMode
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Logger\ExceptionPhalcon\Logger\Adapter\Exceptions\InvalidStreamMode
Uses Phalcon\Logger\Exception
Method Summary
Methods
__construct()
public function __construct();Logger\Adapter\Exceptions\SyslogOpenFailed
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Logger\ExceptionPhalcon\Logger\Adapter\Exceptions\SyslogOpenFailed
Uses Phalcon\Logger\Exception
Method Summary
Methods
__construct()
public function __construct(
string $name,
int $facility
);Logger\Adapter\Noop
ClassSource on GitHubClass Noop
@package Phalcon\Logger\Adapter
Phalcon\Logger\Adapter\AbstractAdapterPhalcon\Logger\Adapter\Noop
Uses Phalcon\Logger\Item
Method Summary
publicboolclose()Closes the streampublicvoidprocess( Item$item )Processes the message i.e. writes it to the fileMethods
close()
public function close(): bool;Closes the stream
process()
public function process( Item $item ): void;Processes the message i.e. writes it to the file
Logger\Adapter\Stream
ClassSource on GitHubPhalcon\Logger\Adapter\Stream
Adapter to store logs in plain text files
$logger = new \Phalcon\Logger\Adapter\Stream('app/logs/test.log');
$logger->log('This is a message');
$logger->log(\Phalcon\Logger\Enum::ERROR, 'This is an error');
$logger->error('This is another error');
$logger->close();@property resource|null $handler @property string $mode @property string $name
Phalcon\Logger\Adapter\AbstractAdapterPhalcon\Logger\Adapter\Stream
Uses Phalcon\Logger\Adapter\Exceptions\FileOpenFailed · Phalcon\Logger\Adapter\Exceptions\InvalidStreamMode · Phalcon\Logger\Item
Method Summary
public__construct(string$name,array$options = [])Stream constructor.publicboolclose()Closes the streampublicstringgetName()Stream namepublicvoidprocess( Item$item )Processes the message i.e. writes it to the fileprotectedboolphpFclose( mixed$handle )@todo to be removed when we get traitsprotectedphpFopen(string$filename,string$mode)@todo to be removed when we get traitsprotectedphpFwrite(mixed$handle,string$message)@todo to be removed when we get traitsProperties
protectedresource|null$handler = nullStream handler resourceprotectedstring$mode = "ab"The file open mode. Defaults to 'ab'protectedstring$nameStream nameMethods
__construct()
public function __construct(
string $name,
array $options = []
);Stream constructor.
close()
public function close(): bool;Closes the stream
getName()
public function getName(): string;Stream name
process()
public function process( Item $item ): void;Processes the message i.e. writes it to the file
phpFclose()
protected function phpFclose( mixed $handle ): bool;@todo to be removed when we get traits
phpFopen()
protected function phpFopen(
string $filename,
string $mode
);@todo to be removed when we get traits
phpFwrite()
protected function phpFwrite(
mixed $handle,
string $message
);@todo to be removed when we get traits
Logger\Adapter\Syslog
ClassSource on GitHubClass Syslog
@property string $defaultFormatter @property int $facility @property string $name @property bool $opened @property int $option
Phalcon\Logger\Adapter\AbstractAdapterPhalcon\Logger\Adapter\Syslog
Uses Phalcon\Logger\Adapter\Exceptions\SyslogOpenFailed · Phalcon\Logger\Enum · Phalcon\Logger\Item
Method Summary
public__construct(string$name,array$options = [])Syslog constructor.publicboolclose()Closes the loggerpublicvoidprocess( Item$item )Processes the message i.e. writes it to the syslogprotectedboolopenlog(string$ident,int$option,int$facility)Open connection to system loggerProperties
protectedint$facility = 0protectedstring$name = ""protectedbool$opened = falseprotectedint$option = 0Methods
__construct()
public function __construct(
string $name,
array $options = []
);Syslog constructor.
close()
public function close(): bool;Closes the logger
process()
public function process( Item $item ): void;Processes the message i.e. writes it to the syslog
openlog()
protected function openlog(
string $ident,
int $option,
int $facility
): bool;Open connection to system logger
@link https://php.net/manual/en/function.openlog.php
Logger\Enum
ClassSource on GitHubLog Level Enum constants
Phalcon\Logger\Enum
Constants
intALERT = 2intCRITICAL = 1intCUSTOM = 8intDEBUG = 7intEMERGENCY = 0intERROR = 3intINFO = 6intNOTICE = 5intTRACE = 9intWARNING = 4Logger\Exception
ClassSource on GitHubPhalcon\Logger\Exception
Exceptions thrown in Phalcon\Logger will use this class
\ExceptionPhalcon\Logger\ExceptionPhalcon\Logger\Adapter\Exceptions\FileOpenFailedPhalcon\Logger\Adapter\Exceptions\InvalidStreamModePhalcon\Logger\Adapter\Exceptions\SyslogOpenFailedPhalcon\Logger\Exceptions\AdapterNotFoundPhalcon\Logger\Exceptions\DeserializationFailedPhalcon\Logger\Exceptions\NoAdaptersConfiguredPhalcon\Logger\Exceptions\SerializationFailedPhalcon\Logger\Exceptions\TransactionAlreadyActivePhalcon\Logger\Exceptions\TransactionNotActive
Logger\Exceptions\AdapterNotFound
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Logger\ExceptionPhalcon\Logger\Exceptions\AdapterNotFound
Uses Phalcon\Logger\Exception
Method Summary
Methods
__construct()
public function __construct( string $name );Logger\Exceptions\DeserializationFailed
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Logger\ExceptionPhalcon\Logger\Exceptions\DeserializationFailed
Uses Phalcon\Logger\Exception
Method Summary
Methods
__construct()
public function __construct();Logger\Exceptions\NoAdaptersConfigured
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Logger\ExceptionPhalcon\Logger\Exceptions\NoAdaptersConfigured
Uses Phalcon\Logger\Exception
Method Summary
Methods
__construct()
public function __construct();Logger\Exceptions\SerializationFailed
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Logger\ExceptionPhalcon\Logger\Exceptions\SerializationFailed
Uses Phalcon\Logger\Exception
Method Summary
Methods
__construct()
public function __construct();Logger\Exceptions\TransactionAlreadyActive
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Logger\ExceptionPhalcon\Logger\Exceptions\TransactionAlreadyActive
Uses Phalcon\Logger\Exception
Method Summary
Methods
__construct()
public function __construct();Logger\Exceptions\TransactionNotActive
ClassSource on GitHubThis file is part of the Phalcon Framework.
(c) Phalcon Team <[email protected]>
For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.
\ExceptionPhalcon\Logger\ExceptionPhalcon\Logger\Exceptions\TransactionNotActive
Uses Phalcon\Logger\Exception
Method Summary
Methods
__construct()
public function __construct();Logger\Formatter\AbstractFormatter
AbstractSource on GitHubClass AbstractFormatter
Phalcon\Support\Helper\Str\AbstractStrPhalcon\Logger\Formatter\AbstractFormatter— implementsPhalcon\Logger\Formatter\FormatterInterface
Uses DateTimeImmutable · Phalcon\Logger\Item · Phalcon\Support\Helper\Str\AbstractStr
Method Summary
publicstringgetDateFormat()publicvoidsetDateFormat( string$format )protectedstringgetFormattedDate( Item$item )Returns the date formatted for the logger.protectedstringgetInterpolatedMessage(Item$item,string$message)Properties
protectedstring$dateFormat = "c"Default date formatprotectedstring$interpolatorLeft = "%"protectedstring$interpolatorRight = "%"Methods
getDateFormat()
public function getDateFormat(): string;setDateFormat()
public function setDateFormat( string $format ): void;getFormattedDate()
protected function getFormattedDate( Item $item ): string;Returns the date formatted for the logger.
getInterpolatedMessage()
protected function getInterpolatedMessage(
Item $item,
string $message
): string;Logger\Formatter\FormatterInterface
InterfaceSource on GitHubPhalcon\Logger\FormatterInterface
This interface must be implemented by formatters in Phalcon\Logger
Phalcon\Logger\Formatter\FormatterInterface
Uses Phalcon\Logger\Item
Method Summary
Methods
format()
public function format( Item $item ): string;Applies a format to an item
Logger\Formatter\Json
ClassSource on GitHubFormats messages using JSON encoding
Phalcon\Support\Helper\Str\AbstractStrPhalcon\Logger\Formatter\AbstractFormatterPhalcon\Logger\Formatter\Json
Uses JsonException · Phalcon\Logger\Item
Method Summary
public__construct(string$dateFormat = "c",string$interpolatorLeft = "%",string$interpolatorRight = "%")Json constructor.publicstringformat( Item$item )Applies a format to a message before sent it to the internal logMethods
__construct()
public function __construct(
string $dateFormat = "c",
string $interpolatorLeft = "%",
string $interpolatorRight = "%"
);Json constructor.
format()
public function format( Item $item ): string;Applies a format to a message before sent it to the internal log
Logger\Formatter\Line
ClassSource on GitHubClass Line
Phalcon\Support\Helper\Str\AbstractStrPhalcon\Logger\Formatter\AbstractFormatterPhalcon\Logger\Formatter\Line
Uses Exception · Phalcon\Logger\Item
Method Summary
public__construct(string$format = "[%date%][%level%] %message%",string$dateFormat = "c",string$interpolatorLeft = "%",string$interpolatorRight = "%")Line constructor.publicstringformat( Item$item )Applies a format to a message before sent it to the internal logpublicstringgetFormat()Return the format applied to each messagepublicstaticsetFormat( string$format )Set the format applied to each messageProperties
protectedstring$formatFormat applied to each messageMethods
__construct()
public function __construct(
string $format = "[%date%][%level%] %message%",
string $dateFormat = "c",
string $interpolatorLeft = "%",
string $interpolatorRight = "%"
);Line constructor.
format()
public function format( Item $item ): string;Applies a format to a message before sent it to the internal log
getFormat()
public function getFormat(): string;Return the format applied to each message
setFormat()
public function setFormat( string $format ): static;Set the format applied to each message
Logger\Item
ClassSource on GitHubPhalcon\Logger\Item
Represents each item in a logging transaction
@property array $context @property string $message @property int $level @property string $levelName @property DateTimeImmutable $dateTime
Phalcon\Logger\Item
Uses DateTimeImmutable
Method Summary
public__construct(string$message,string$levelName,int$level,DateTimeImmutable$dateTime,array$context = [])Item constructor.publicarraygetContext()publicDateTimeImmutablegetDateTime()publicintgetLevel()publicstringgetLevelName()publicstringgetMessage()Properties
protectedarray$context = []protectedDateTimeImmutable$dateTimeprotectedint$levelprotectedstring$levelNameprotectedstring$messageMethods
__construct()
public function __construct(
string $message,
string $levelName,
int $level,
DateTimeImmutable $dateTime,
array $context = []
);Item constructor.
getContext()
public function getContext(): array;getDateTime()
public function getDateTime(): DateTimeImmutable;getLevel()
public function getLevel(): int;getLevelName()
public function getLevelName(): string;getMessage()
public function getMessage(): string;Logger\Logger
ClassSource on GitHubPhalcon Logger.
A logger, with various adapters and formatters. A formatter interface is available as well as an adapter one. Adapters can be created easily using the built-in AdapterFactory. A LoggerFactory is also available that allows developers to create new instances of the Logger or load them from config files (see Phalcon\Config\Config object).
Phalcon\Logger\AbstractLoggerPhalcon\Logger\Logger— implementsPhalcon\Logger\LoggerInterface
Uses Exception · Phalcon\Logger\Exception
Method Summary
publicvoidalert(string$message,array$context = [])Action must be taken immediately.publicvoidcritical(string$message,array$context = [])Critical conditions.publicvoiddebug(string$message,array$context = [])Detailed debug information.publicvoidemergency(string$message,array$context = [])System is unusable.publicvoiderror(string$message,array$context = [])Runtime errors that do not require immediate action but should typicallypublicvoidinfo(string$message,array$context = [])Interesting events.publicvoidlog(mixed$level,string$message,array$context = [])Logs with an arbitrary level.publicvoidnotice(string$message,array$context = [])Normal but significant events.publicvoidtrace(string$message,array$context = [])Extra-verbose diagnostic output.publicvoidwarning(string$message,array$context = [])Exceptional occurrences that are not errors.Methods
alert()
public function alert(
string $message,
array $context = []
): void;Action must be taken immediately.
Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.
critical()
public function critical(
string $message,
array $context = []
): void;Critical conditions.
Example: Application component unavailable, unexpected exception.
debug()
public function debug(
string $message,
array $context = []
): void;Detailed debug information.
emergency()
public function emergency(
string $message,
array $context = []
): void;System is unusable.
error()
public function error(
string $message,
array $context = []
): void;Runtime errors that do not require immediate action but should typically be logged and monitored.
info()
public function info(
string $message,
array $context = []
): void;Interesting events.
Example: User logs in, SQL logs.
log()
public function log(
mixed $level,
string $message,
array $context = []
): void;Logs with an arbitrary level.
notice()
public function notice(
string $message,
array $context = []
): void;Normal but significant events.
trace()
public function trace(
string $message,
array $context = []
): void;Extra-verbose diagnostic output.
Use for high-frequency, fine-grained events such as raw socket frames, HTTP response bodies, or internal state transitions that are too noisy for DEBUG.
warning()
public function warning(
string $message,
array $context = []
): void;Exceptional occurrences that are not errors.
Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.
Logger\LoggerFactory
ClassSource on GitHubFactory creating logger objects
Phalcon\Factory\AbstractConfigFactoryPhalcon\Logger\LoggerFactory
Uses DateTimeZone · Phalcon\Config\ConfigInterface · Phalcon\Factory\AbstractConfigFactory
Method Summary
public__construct( AdapterFactory$factory )publicLoggerload( mixed$config )Factory to create an instance from a Config objectpublicLoggernewInstance(string$name,array$adapters = [],DateTimeZone$timezone = null)Returns a Logger objectprotectedmixedgetArrVal(array$collection,mixed$index,mixed$defaultValue = null)@todo Remove this when we get traitsprotectedstringgetExceptionClass()Methods
__construct()
public function __construct( AdapterFactory $factory );load()
public function load( mixed $config ): Logger;Factory to create an instance from a Config object
newInstance()
public function newInstance(
string $name,
array $adapters = [],
DateTimeZone $timezone = null
): Logger;Returns a Logger object
getArrVal()
protected function getArrVal(
array $collection,
mixed $index,
mixed $defaultValue = null
): mixed;@todo Remove this when we get traits
getExceptionClass()
protected function getExceptionClass(): string;Logger\LoggerInterface
InterfaceSource on GitHubInterface for Phalcon based logger objects.
Phalcon\Logger\LoggerInterface
Uses Phalcon\Logger\Adapter\AdapterInterface
Method Summary
publicvoidalert(string$message,array$context = [])Action must be taken immediately.publicvoidcritical(string$message,array$context = [])Critical conditions.publicvoiddebug(string$message,array$context = [])Detailed debug information.publicvoidemergency(string$message,array$context = [])System is unusable.publicvoiderror(string$message,array$context = [])Runtime errors that do not require immediate action but should typicallypublicAdapterInterfacegetAdapter( string$name )Returns an adapter from the stackpublicarraygetAdapters()Returns the adapter stack arraypublicintgetLogLevel()Returns the log levelpublicstringgetName()Returns the name of the loggerpublicvoidinfo(string$message,array$context = [])Interesting events.publicvoidlog(mixed$level,string$message,array$context = [])Logs with an arbitrary level.publicvoidnotice(string$message,array$context = [])Normal but significant events.publicvoidtrace(string$message,array$context = [])Extra-verbose diagnostic output.publicvoidwarning(string$message,array$context = [])Exceptional occurrences that are not errors.Methods
alert()
public function alert(
string $message,
array $context = []
): void;Action must be taken immediately.
Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.
critical()
public function critical(
string $message,
array $context = []
): void;Critical conditions.
Example: Application component unavailable, unexpected exception.
debug()
public function debug(
string $message,
array $context = []
): void;Detailed debug information.
emergency()
public function emergency(
string $message,
array $context = []
): void;System is unusable.
error()
public function error(
string $message,
array $context = []
): void;Runtime errors that do not require immediate action but should typically be logged and monitored.
getAdapter()
public function getAdapter( string $name ): AdapterInterface;Returns an adapter from the stack
getAdapters()
public function getAdapters(): array;Returns the adapter stack array
getLogLevel()
public function getLogLevel(): int;Returns the log level
getName()
public function getName(): string;Returns the name of the logger
info()
public function info(
string $message,
array $context = []
): void;Interesting events.
Example: User logs in, SQL logs.
log()
public function log(
mixed $level,
string $message,
array $context = []
): void;Logs with an arbitrary level.
notice()
public function notice(
string $message,
array $context = []
): void;Normal but significant events.
trace()
public function trace(
string $message,
array $context = []
): void;Extra-verbose diagnostic output.
warning()
public function warning(
string $message,
array $context = []
): void;Exceptional occurrences that are not errors.
Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.