RadPHP Logging Component

Related tags

Logging logging
Overview

RadPHP Logging Component

License Total Downloads

The Logging library provides multiple logging adapters using a simple interface. With the Logger class it is possible to send a single message to multiple logging adapters at the same time.

By default you can use File or Null as logging adapters, but you can use any object implementing Rad\Logging\AdapterInterface as an adapter for the Logger class.

Usage

You can create new instance adapter and attached to the Logger class. An example would be:

use Rad\Logging\Logger;
use Rad\Logging\Adapter\FileAdapter;

// Attach single or multiple adapters
$logger = new Logger();

$logger->attachAdapter(new NullAdapter());
$logger->attachAdapter(new FileAdapter('/path/to/file.log'));
// Or attaching your adapter
$logger->attachAdapter(new MyAdapter());

// You can pass message to these log levels
$logger->emergency('Something did not work');
$logger->alert('Something did not work');
$logger->critical('Something did not work');
$logger->error('Something did not work');
$logger->warning('Something did not work');
$logger->notice('Something did not work');
$logger->info('Something did not work');
$logger->debug('Something did not work');

The log output is below:

09/Apr/2016 11:18:55 UTC [EMERGENCY] Something did not work
09/Apr/2016 11:18:55 UTC [ALERT] Something did not work
09/Apr/2016 11:18:55 UTC [CRITICAL] Something did not work
09/Apr/2016 11:18:55 UTC [ERROR] Something did not work
09/Apr/2016 11:18:55 UTC [WARNING] Something did not work
09/Apr/2016 11:18:55 UTC [NOTICE] Something did not work
09/Apr/2016 11:18:55 UTC [INFO] Something did not work
09/Apr/2016 11:18:55 UTC [DEBUG] Something did not work

The log message may contain placeholders. Placeholder names must correspond to keys in the context array. Placeholder names must be delimited with a single opening brace { and a single closing brace }. There must not be any whitespace between the delimiters and the placeholder name. Placeholder names should be composed only of the characters A-Z, a-z, 0-9, underscore _, and period .. The use of other characters is reserved for future modifications of the placeholders specification.

The following is an example uses placeholder in log message:

2]);">
use Rad\Logging\Logger;
use Rad\Logging\Adapter\FileAdapter;

$logger = new Logger();
$logger->attachAdapter(new FileAdapter('/path/to/file.log'));
$logger->info('User "{user_id}" successfully logged in.', ['user_id' => 2]);

Transactions

Transactions store log data temporarily in memory and later on write the data to all adapters.

use Rad\Logging\Logger;
use Rad\Logging\Adapter\FileAdapter;

$logger = new Logger();
$logger->attachAdapter(new FileAdapter('/path/to/file.log'));

$logger->begin();
try {
    //Code here
    $logger->commit();
} catch (\Exception $e) {
    $logger->rollback();
    throw $e;
}

Formatter

You can use formatter for format log lines or implementing your own formatter. Your formatter must be implemented Rad\Logging\FormatterInterface, Default formatter is LineFormatter

attachAdapter($fileAdapter); $logger->emergency('Something did not work'); $logger->alert('Something did not work');">
use Rad\Logging\Logger;
use Rad\Logging\Adapter\FileAdapter;

$logger = new Logger();

$fileAdapter = new FileAdapter('/path/to/file.log');
$fileAdapter->setFormatter(new LineFormatter("%time% :: {%level%} :: %message%\n", 'G:i:s T'));
$logger->attachAdapter($fileAdapter);

$logger->emergency('Something did not work');
$logger->alert('Something did not work');

The log output with new format:

11:18:55 UTC :: {EMERGENCY} :: Something did not work
11:18:55 UTC :: {ALERT} :: Something did not work

These variables available for LineFormatter:

Variables Description
%time% Log time
%level% Log level
%message% Log message
You might also like...
Application for logging HTTP and DNS Requests

Request Logger Made by Adam Langley ( https://twitter.com/adamtlangley ) What is it? Request logger is a free and open source utility for logging HTTP

Emoncms is an open-source web application for processing, logging and visualising energy, temperature and other environmental data and is part of the OpenEnergyMonitor project.
Emoncms is an open-source web application for processing, logging and visualising energy, temperature and other environmental data and is part of the OpenEnergyMonitor project.

Emoncms is an open-source web application for processing, logging and visualising energy, temperature and other environmental data and is part of the OpenEnergyMonitor project.

This package is for centralized logging of multiple Laravel application into one connection.

Laralogs This package is for centralized logging of multiple Laravel application into one connection. Installation You can install the package via com

Simple blog concept with features such authentication (creating accounts, logging in) and commenting.
Simple blog concept with features such authentication (creating accounts, logging in) and commenting.

Simple blog concept with features such authentication (creating accounts, logging in) and commenting. Styling done with tailwindcss and inline javascript is provided by alpineJS.

Here is an Instagram Guest API. Gather all public information as JSON format without logging yourself.

Here is an Instagram Guest API. Gather all public information as JSON format without logging yourself. It's all automation and time saving.

The package provides the ability to write logs into the database synchronously or asynchronously, along with other logging channels.

Laravel database log channel The package provides the ability to write logs into the database synchronously or asynchronously, along with other loggin

A simple Laravel event log package for easy model based logging.

Karacraft Logman A simple Model Event Logging Package Usage Installation composer require karacraft/logman Migrate php artisan migrate Publish php a

Best logging support into Nette Framework (@nette)
Best logging support into Nette Framework (@nette)

Website 🚀 contributte.org | Contact 👨🏻‍💻 f3l1x.io | Twitter 🐦 @contributte Usage To install the latest version of contributte/monolog use Compose

A PocketMine-MP plugin for logging Exceptions to a Sentry server
A PocketMine-MP plugin for logging Exceptions to a Sentry server

Sentry A PocketMine-MP plugin for logging Exceptions to a Sentry server. Asynchronous logging If you want to log exceptions in a thread-safe way, you

Monolog logging support for Slim Framework

Monolog Logging for Slim Framework This repository adds support for logging to Monolog to the Slim Framework. Installation MonologWriter takes an arra

High-performance API performing logging for PHP applications into files or SysLog

Logging API Table of contents: About Configuration Binding Points Logging Installation Unit Tests Reference Guide Specifications How Are Log Lines For

Logging formatters for ECS

ECS Logging for PHP Transform your application logs to structured logs that comply with the Elastic Common Schema (ECS). In combination with Filebeat,

A horrendous PM plugin to manually load all the chunks in your world without logging on. Only for the sole purpose of aiding in PM4 - DF world conversion.

ChunkLoader A horrendous PM plugin to manually load all the chunks in your world without logging on. Only for the sole purpose of aiding in PM4 - DF

PocketMine-MP To Discord Chat Logging.
PocketMine-MP To Discord Chat Logging.

Welcome To PocketCord PocketCord is a PocketMine-MP plugin designed to link discord and your PocketMine-MP Server with quick and easy setup! Installat

A powerful command line application framework for PHP. It's an extensible, flexible component, You can build your command-based application in seconds!
A powerful command line application framework for PHP. It's an extensible, flexible component, You can build your command-based application in seconds!

CLIFramework CLIFramework is a command-line application framework, for building flexiable, simple command-line applications. Commands and Subcommands

ReactPHP Shell, based on the Symfony Console component.

Pecan Event-driven, non-blocking shell for ReactPHP. Pecan (/pɪˈkɑːn/) provides a non-blocking alternative to the shell provided in the Symfony Consol

Authentication component from Zend Framework

zend-authentication Repository abandoned 2019-12-31 This repository has moved to laminas/laminas-authentication. The Zend\Authentication component pro

The VarDumper component provides mechanisms for walking through any arbitrary PHP variable. It provides a better dump() function that you can use instead of var_dump().

VarDumper Component The VarDumper component provides mechanisms for walking through any arbitrary PHP variable. It provides a better dump() function t

[READ ONLY] Subtree split of the Illuminate Database component (see laravel/framework)

Illuminate Database The Illuminate Database component is a full database toolkit for PHP, providing an expressive query builder, ActiveRecord style OR

Owner
RadPHP
RadPHP is a rapid RESTful application development PHP framework based on ADR pattern
RadPHP
PHP logging library that is highly extendable and simple to use.

Analog - Minimal PHP logging library Copyright: (c) 2012-Present Johnny Broadway License: MIT A minimal PHP logging package based on the idea of using

Aband*nthecar 331 Dec 21, 2022
🐣 Backend-Logging aller Aktionen im Backend

Addon BE_Logger - Backend-Logging Mit dem Addon be_logger können die Backend-Zugriffe aller Benutzer in einer Logging-Tabelle ausgegeben werden. Es gi

Friends Of REDAXO 14 Sep 12, 2022
This package is for centralized logging of multiple Laravel application into one connection.

Laralogs This package is for centralized logging of multiple Laravel application into one connection. Installation You can install the package via com

Remon 4 Apr 26, 2022
Monolog logging support for Slim Framework

Monolog Logging for Slim Framework This repository adds support for logging to Monolog to the Slim Framework. Installation MonologWriter takes an arra

null 113 Dec 18, 2022
High-performance API performing logging for PHP applications into files or SysLog

Logging API Table of contents: About Configuration Binding Points Logging Installation Unit Tests Reference Guide Specifications How Are Log Lines For

Lucian Gabriel Popescu 0 Jan 9, 2022
😎 Tracy: the addictive tool to ease debugging PHP code for cool developers. Friendly design, logging, profiler, advanced features like debugging AJAX calls or CLI support. You will love it.

Tracy - PHP debugger Introduction Tracy library is a useful helper for everyday PHP programmers. It helps you to: quickly detect and correct errors lo

Nette Foundation 1.6k Dec 23, 2022
A Simple Logging Class For PHP

KLogger: Simple Logging for PHP A project written by Kenny Katzgrau and Dan Horrigan. About KLogger is an easy-to-use PSR-3 compliant logging class fo

Kenny Katzgrau 964 Dec 11, 2022
PHP logging library that is highly extendable and simple to use.

Analog - Minimal PHP logging library Copyright: (c) 2012-Present Johnny Broadway License: MIT A minimal PHP logging package based on the idea of using

Aband*nthecar 331 Dec 21, 2022
Manage all your cron jobs without modifying crontab. Handles locking, logging, error emails, and more.

Jobby, a PHP cron job manager Install the master jobby cron job, and it will manage all your offline tasks. Add jobs without modifying crontab. Jobby

null 1k Dec 25, 2022
🐣 Backend-Logging aller Aktionen im Backend

Addon BE_Logger - Backend-Logging Mit dem Addon be_logger können die Backend-Zugriffe aller Benutzer in einer Logging-Tabelle ausgegeben werden. Es gi

Friends Of REDAXO 14 Sep 12, 2022