Using a logger content. Respecting the PHP PSR-6

1.0.1 2020-11-03 17:28 UTC

This package is auto-updated.

Last update: 2024-06-29 05:10:48 UTC


PHP Packagist version Packagist License Gitlab pipeline status


Do you want to log any content in a file or... more widely, by a stream ! This librairy allows you to do that. Want database logs, system logs, connexion logs... anything you want is possible with a bit of knowledge.

This librairy use the PHP PSR-3.


This is a php package downloadable from packagist, which is used composer.

Composer from bash

composer require nolikein/logger ^1.0.0

Composer from Docker:

docker run --rm --interactive --tty -v $PWD:/app composer require nolikein/logger ^1.0.0


Level 1 - Bases

use Nolikein\Stream\StreamFactory;
use Nolikein\Logger\StreamLogger;

// Open a file with the Stream Manager librairy (a file is a stream opened)
$fileStream = (new StreamFactory())->createStreamFromFile(__DIR__.'/logfile_name.log', 'r+');

// Creating a new logger instance
$logger = new StreamLogger($fileStream);

// Write a log
$logger->log($level='notice', $message='My log message');

// There are as many methods as there are log levels.
$logger->notice('I want to notice you of something');

All log level are described in the Psr\Log\LogLevel class.

Level 2 - Replacing text

// Replace logged text by using "context"
$logger->notice($message='It is {something} time !', $context=['something', 'muffin']);

Will output: It is muffin time !



You can contribute as you want. I have no rules.


The project is under lincence MIT.