Secciones

Abstract Class Phalcon\Logger\AbstractLogger

Código fuente en GitHub

Namespace Phalcon\Logger   Uses DateTimeImmutable, DateTimeZone, Exception, Phalcon\Logger\Exception, Phalcon\Logger\Adapter\AdapterInterface

Abstract 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).

Constantes

const ALERT = 2;
const CRITICAL = 1;
const CUSTOM = 8;
const DEBUG = 7;
const EMERGENCY = 0;
const ERROR = 3;
const INFO = 6;
const NOTICE = 5;
const WARNING = 4;

Propiedades

/**
 * The adapter stack
 *
 * @var AdapterInterface[]
 */
protected adapters;

/**
 * The excluded adapters for this log process
 *
 * @var array
 */
protected excluded;

/**
 * Minimum log level for the logger
 *
 * @var int
 */
protected logLevel = 8;

/**
 * @var string
 */
protected name = ;

/**
 * @var DateTimeZone
 */
protected timezone;

Métodos

public function __construct( string $name, array $adapters = [], DateTimeZone $timezone = null );

Constructor.

public function addAdapter( string $name, AdapterInterface $adapter ): AbstractLogger;

Añade un adaptador a la pila. Para el procesamiento usamos FIFO

public function excludeAdapters( array $adapters = [] ): AbstractLogger;

Excluye ciertos adaptadores.

public function getAdapter( string $name ): AdapterInterface;

Devuelve un adaptador de la pila

public function getAdapters(): array;

Devuelve el vector de la pila de adaptadores

public function getLogLevel(): int;

Returns the log level

public function getName(): string;

Devuelve el nombre del registrador

public function removeAdapter( string $name ): AbstractLogger;

Elimina un adaptador de la pila

public function setAdapters( array $adapters ): AbstractLogger;

Establece la pila de adaptadores sobreescribiendo lo que ya existe

public function setLogLevel( int $level ): AbstractLogger;

Establece la pila de adaptadores sobreescribiendo lo que ya existe

protected function addMessage( int $level, string $message, array $context = [] ): bool;

Añade un mensaje a cada manejador para procesar

protected function getLevelNumber( mixed $level ): int;

Converts the level from string/word to an integer

protected function getLevels(): array;

Devuelve un vector de niveles de registro con conversión de entero a cadena

Abstract Class Phalcon\Logger\Adapter\AbstractAdapter

Código fuente en GitHub

Namespace Phalcon\Logger\Adapter   Uses Phalcon\Logger\Exception, Phalcon\Logger\Formatter\FormatterInterface, Phalcon\Logger\Formatter\Line, Phalcon\Logger\Item   Implements AdapterInterface

Class AbstractAdapter

Propiedades

/**
 * Name of the default formatter class
 *
 * @var string
 */
protected defaultFormatter = Phalcon\\Logger\Formatter\\Line;

/**
 * Formatter
 *
 * @var FormatterInterface|null
 */
protected formatter;

/**
 * Tells if there is an active transaction or not
 *
 * @var bool
 */
protected inTransaction = false;

/**
 * Array with messages queued in the transaction
 *
 * @var array
 */
protected queue;

Métodos

public function __destruct();

Limpieza del destructor

@throws Exception

public function __serialize(): array;

Prevent serialization

public function __unserialize( array $data ): void;

Prevent unserialization

public function add( Item $item ): AdapterInterface;

Añade un mensaje a la cola

public function begin(): AdapterInterface;

Inicia una transacción

public function commit(): AdapterInterface;

Confirma la transacción interna

public function getFormatter(): FormatterInterface;
public function inTransaction(): bool;

Devuelve si el registrador está actualmente en una transacción activa o no

abstract public function process( Item $item ): void;

Procesa el mensaje en el adaptador

public function rollback(): AdapterInterface;

Deshace la transacción interna

public function setFormatter( FormatterInterface $formatter ): AdapterInterface;

Establece el formateador de mensajes

protected function getFormattedItem( Item $item ): string;

Returns the formatted item

Interface Phalcon\Logger\Adapter\AdapterInterface

Código fuente en GitHub

Namespace Phalcon\Logger\Adapter   Uses Phalcon\Logger\Formatter\FormatterInterface, Phalcon\Logger\Item

Phalcon\Logger\AdapterInterface

Interfaz para adaptadores Phalcon\Logger

Métodos

public function add( Item $item ): AdapterInterface;

Añade un mensaje en la cola

public function begin(): AdapterInterface;

Inicia una transacción

public function close(): bool;

Cierra el registrador

public function commit(): AdapterInterface;

Confirma la transacción interna

public function getFormatter(): FormatterInterface;

Devuelve el formateador interno

public function inTransaction(): bool;

Devuelve si el registrador está actualmente en una transacción activa o no

public function process( Item $item ): void;

Procesa el mensaje en el adaptador

public function rollback(): AdapterInterface;

Deshace la transacción interna

public function setFormatter( FormatterInterface $formatter ): AdapterInterface;

Establece el formateador de mensajes

Class Phalcon\Logger\Adapter\Noop

Código fuente en GitHub

Namespace Phalcon\Logger\Adapter   Uses Phalcon\Logger\Item   Extends AbstractAdapter

Class Noop

@package Phalcon\Logger\Adapter

Métodos

public function close(): bool;

Cierra el flujo

public function process( Item $item ): void;

Procesa el mensaje, es decir, lo escribe en el fichero

Class Phalcon\Logger\Adapter\Stream

Código fuente en GitHub

Namespace Phalcon\Logger\Adapter   Uses LogicException, Phalcon\Logger\Exception, Phalcon\Logger\Item   Extends AbstractAdapter

Phalcon\Logger\Adapter\Stream

Adaptador para almacenar registros en fichero de texto simple

$logger = new \Phalcon\Logger\Adapter\Stream('app/logs/test.log');

$logger->log('This is a message');
$logger->log(\Phalcon\Logger::ERROR, 'This is an error');
$logger->error('This is another error');

$logger->close();

Propiedades

/**
 * The file open mode. Defaults to 'ab'
 *
 * @var string
 */
protected mode = ab;

/**
 * Stream name
 *
 * @var string
 */
protected name;

/**
 * Path options
 *
 * @var array
 */
protected options;

Métodos

public function __construct( string $name, array $options = [] );

Constructor Stream.

public function close(): bool;

Cierra el flujo

public function getName(): string;

Stream name

public function process( Item $item ): void;

Procesa el mensaje, es decir, lo escribe en el fichero

protected function phpFopen( string $filename, string $mode );

@todo to be removed when we get traits

Class Phalcon\Logger\Adapter\Syslog

Código fuente en GitHub

Namespace Phalcon\Logger\Adapter   Uses LogicException, Phalcon\Logger\Item, Phalcon\Logger\Logger   Extends AbstractAdapter

Class Syslog

Propiedades

/**
 * @var int
 */
protected facility = 0;

/**
 * @var string
 */
protected name = ;

/**
 * @var bool
 */
protected opened = false;

/**
 * @var int
 */
protected option = 0;

Métodos

public function __construct( string $name, array $options = [] );

Syslog constructor.

public function close(): bool;

Cierra el registrador

public function process( Item $item ): void;

Procesa el mensaje, es decir, lo escribe en el syslog

protected function openlog( string $ident, int $option, int $facility ): bool;

Open connection to system logger

@link https://php.net/manual/en/function.openlog.php

Class Phalcon\Logger\AdapterFactory

Código fuente en GitHub

Namespace Phalcon\Logger   Uses Phalcon\Factory\AbstractFactory, Phalcon\Logger\Adapter\AdapterInterface, Phalcon\Logger\Exception   Extends AbstractFactory

Factory used to create adapters used for Logging

Métodos

public function __construct( array $services = [] );

Constructor AdapterFactory.

public function newInstance( string $name, string $fileName, array $options = [] ): AdapterInterface;

Crea una nueva instancia del adaptador

protected function getExceptionClass(): string;
protected function getServices(): array;

Devuelve los adaptadores disponibles

Class Phalcon\Logger\Enum

Código fuente en GitHub

Namespace Phalcon\Logger

Log Level Enum constants

Constantes

const ALERT = 2;
const CRITICAL = 1;
const CUSTOM = 8;
const DEBUG = 7;
const EMERGENCY = 0;
const ERROR = 3;
const INFO = 6;
const NOTICE = 5;
const WARNING = 4;

Class Phalcon\Logger\Exception

Código fuente en GitHub

Namespace Phalcon\Logger   Extends \Exception

Phalcon\Logger\Exception

Las excepciones lanzadas en Phalcon\Logger usarán esta clase

Abstract Class Phalcon\Logger\Formatter\AbstractFormatter

Código fuente en GitHub

Namespace Phalcon\Logger\Formatter   Uses DateTimeImmutable, Phalcon\Logger\Item, Phalcon\Support\Helper\Str\AbstractStr   Extends AbstractStr   Implements FormatterInterface

Class AbstractFormatter

Propiedades

/**
 * Default date format
 *
 * @var string
 */
protected dateFormat = c;

Métodos

public function getDateFormat(): string;

Return the default date format

public function setDateFormat( string $format ): void;

Set the default date format

protected function getFormattedDate( Item $item ): string;

Devuelve la fecha formateada para el registrador.

Interface Phalcon\Logger\Formatter\FormatterInterface

Código fuente en GitHub

Namespace Phalcon\Logger\Formatter   Uses Phalcon\Logger\Item

Phalcon\Logger\FormatterInterface

Se debe implementar esta interfaz por los formateadores en Phalcon\Logger

Métodos

public function format( Item $item ): string;

Aplica un formato a un elemento

Class Phalcon\Logger\Formatter\Json

Código fuente en GitHub

Namespace Phalcon\Logger\Formatter   Uses JsonException, Phalcon\Logger\Item   Extends AbstractFormatter

Formatea mensajes utilizando la codificación JSON

Métodos

public function __construct( string $dateFormat = string );

Json constructor.

public function format( Item $item ): string;

Aplica un formato a un mensaje antes de enviarlo al registro interno

Class Phalcon\Logger\Formatter\Line

Código fuente en GitHub

Namespace Phalcon\Logger\Formatter   Uses Exception, Phalcon\Logger\Item   Extends AbstractFormatter

Class Line

Propiedades

/**
 * Format applied to each message
 *
 * @var string
 */
protected format;

Métodos

public function __construct( string $format = string, string $dateFormat = string );

Line constructor.

public function format( Item $item ): string;

Aplica un formato a un mensaje antes de enviarlo al registro interno

public function getFormat(): string;

Return the format applied to each message

public function setFormat( string $format ): Line;

Set the format applied to each message

Class Phalcon\Logger\Item

Código fuente en GitHub

Namespace Phalcon\Logger   Uses DateTimeImmutable

Phalcon\Logger\Item

Representa cada objeto en una transacción de registro

Propiedades

/**
 * @var array
 */
protected context;

/**
 * @var DateTimeImmutable
 */
protected dateTime;

/**
 * @var string
 */
protected message;

/**
 * @var int
 */
protected level;

/**
 * @var string
 */
protected levelName;

Métodos

public function __construct( string $message, string $levelName, int $level, DateTimeImmutable $dateTime, array $context = [] );

Constructor Item.

public function getContext(): array;
public function getDateTime(): DateTimeImmutable;
public function getLevel(): int;
public function getLevelName(): string;
public function getMessage(): string;

Class Phalcon\Logger\Logger

Código fuente en GitHub

Namespace Phalcon\Logger   Uses Exception, Phalcon\Logger\Exception   Extends AbstractLogger   Implements LoggerInterface

Phalcon 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).

Métodos

public function alert( string $message, array $context = [] ): void;

Se deben tomar medidas de inmediato.

Ejemplo: Sitio web completo, base de datos no disponible, etc. Esto debería activar las alertas de SMS y despertarte.

public function critical( string $message, array $context = [] ): void;

Condiciones críticas.

Ejemplo: Componente de aplicación no disponible, excepción inesperada.

public function debug( string $message, array $context = [] ): void;

Información detallada de depuración.

public function emergency( string $message, array $context = [] ): void;

El sistema está inutilizable.

public function error( string $message, array $context = [] ): void;

Errores en tiempo de ejecución que no requieren una acción inmediata, pero normalmente deberían ser registrados y monitoreados.

public function info( string $message, array $context = [] ): void;

Eventos interesantes.

Ejemplo: Inicio de sesión de usuario, registros SQL.

public function log( mixed $level, string $message, array $context = [] ): void;

Registros con un nivel arbitrario.

public function notice( string $message, array $context = [] ): void;

Eventos normales pero significativos.

public function warning( string $message, array $context = [] ): void;

Ocurrencias excepcionales que no son errores.

Ejemplo: Uso de APIs obsoletas, mal uso de una API, cosas indeseables que no necesariamente son erróneas.

Class Phalcon\Logger\LoggerFactory

Código fuente en GitHub

Namespace Phalcon\Logger   Uses DateTimeZone, Phalcon\Config\ConfigInterface, Phalcon\Factory\AbstractConfigFactory   Extends AbstractConfigFactory

Factory creating logger objects

Propiedades

/**
 * @var AdapterFactory
 */
private adapterFactory;

Métodos

public function __construct( AdapterFactory $factory );
public function load( mixed $config ): Logger;

Factoría para crear una instancia desde un objeto Config

public function newInstance( string $name, array $adapters = [], DateTimeZone $timezone = null ): Logger;

Devuelve un objeto Logger

protected function getArrVal( array $collection, mixed $index, mixed $defaultValue = null ): mixed;

@todo Remove this when we get traits

protected function getExceptionClass(): string;

Interface Phalcon\Logger\LoggerInterface

Código fuente en GitHub

Namespace Phalcon\Logger   Uses Phalcon\Logger\Adapter\AdapterInterface

Interface for Phalcon based logger objects.

Métodos

public function alert( string $message, array $context = [] ): void;

Se deben tomar medidas de inmediato.

Ejemplo: Sitio web completo, base de datos no disponible, etc. Esto debería activar las alertas de SMS y despertarte.

public function critical( string $message, array $context = [] ): void;

Condiciones críticas.

Ejemplo: Componente de aplicación no disponible, excepción inesperada.

public function debug( string $message, array $context = [] ): void;

Información detallada de depuración.

public function emergency( string $message, array $context = [] ): void;

El sistema está inutilizable.

public function error( string $message, array $context = [] ): void;

Errores en tiempo de ejecución que no requieren una acción inmediata, pero normalmente deberían ser registrados y monitoreados.

public function getAdapter( string $name ): AdapterInterface;

Devuelve un adaptador de la pila

public function getAdapters(): array;

Devuelve el vector de la pila de adaptadores

public function getLogLevel(): int;

Returns the log level

public function getName(): string;

Devuelve el nombre del registrador

public function info( string $message, array $context = [] ): void;

Eventos interesantes.

Ejemplo: Inicio de sesión de usuario, registros SQL.

public function log( mixed $level, string $message, array $context = [] ): void;

Registros con un nivel arbitrario.

public function notice( string $message, array $context = [] ): void;

Eventos normales pero significativos.

public function warning( string $message, array $context = [] ): void;

Eventos normales pero significativos.