Skip to content

Latest commit

 

History

History
100 lines (65 loc) · 3 KB

api-log.md

File metadata and controls

100 lines (65 loc) · 3 KB

Log Component

Introduction

Log is a component that allows writing application logs using files, sockets, inboxes, databases and various web services.

Features

Log features:

- Support for storing logs in files, databases or cloud storages - Decorators for monolog formatters - Decorators for monolog handlers - Decorators for monolog processors - PSR-3 compatibility - Kraken Framework compatibility

Examples

This section contains examples and patterns that can be used with described component.

Creating Logger

To create logger use this syntax:

$logger = new Logger($loggerName, $loggers, $processors);

Logging

Logging uses the same interface as PSR-3 or Monolog, so you can use methods such as emergency, alert, critical, error, warning, notice, info, debug and others.

The log method is also supported:

$logger->log($logger::WARNING, 'Something went wrong!', $context);

Creating Monolog Handlers

Creating monolog handlers wrapped in Kraken-compatible interface can be done using:

$handler = $loggerFactory->createHandler($handlerNameOrClass, $handlerArgs);

Creating Monolog Processors

Creating monolog processors wrapped in Kraken-compatible interface can be done using:

$processor = $loggerFactory->createProcessor($processorNameOrClass, $processorArgs);

Creating Monolog Formatters

Creating monolog formatters wrapped in Kraken-compatible interface can be done using:

$formatter = $loggerFactory->createFormatter($formatterNameOrClass, $formatterArgs);

Important Classes & Interfaces

This section contains list of most important classes and interfaces shipped with this component. It does not include all classes and interface.

Logger

class Logger implements LoggerInterface

It is an implementation of logger using monolog logger as its model.

LoggerInterface

interface LoggerInterface extends EnumInterface, PsrLoggerInterface

PSR-3 compatible interface for logging.

LoggerFactory

class LoggerFactory

Factory for creating Kraken-compatible instances of Monolog handlers, processors and formatters.