PHPackages                             gd-75/simple-logger - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. gd-75/simple-logger

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

gd-75/simple-logger
===================

A simple PSR-3 compliant PHP logger

1.0.0(5y ago)114MITPHPPHP &gt;=7.4

Since Feb 12Pushed 5y agoCompare

[ Source](https://github.com/gd-75/simple-logger)[ Packagist](https://packagist.org/packages/gd-75/simple-logger)[ RSS](/packages/gd-75-simple-logger/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

SimpleLogger
============

[](#simplelogger)

Simple PSR-3 compliant logger; less than 200 SLOC and 4 files.

Only one dependency, `psr/log`, use this package with confidence.

This was originally a library that I developed for my own projects, but I thought it might be worth sharing. If you have any comments or spot a bug, feel free to open an issue.

Tests will eventually come later.

Features
--------

[](#features)

### Global minimal log level

[](#global-minimal-log-level)

Define a global minimal log level, useful when switching from development (DEBUG) to development (INFO or even NOTICE).

### Custom writers with individual minimal level

[](#custom-writers-with-individual-minimal-level)

The default writer writes to local log files, but if you want something else, feel free to create a custom writer, implement a single method present in the `SimpleLoggerWriterInterface`, pass it to the logger and you are good to go. As and added bonus, you can define a higher minimal level per writer. For example: all the logs go to the log file and only the critical ones go through your custom writer.

### Logger proxies

[](#logger-proxies)

Useful when a prefix needs to be prepended to a log message, for example inside a service class or a controller. Instead of the log message being

> \[INFO\] Blah

it becomes

> \[INFO\]\[Context\] Blah

This is done through the use of a lightweight wrapper class that references a single global `SimpleLogger` instance, meaning you save on

- time: do not manually prefix your log message for each class
- resources: there is only one "heavy" instance of the logger and its writers, the proxies are, well, proxies

Installation
------------

[](#installation)

```
composer require gd-75/simple-logger
```

Usage
-----

[](#usage)

Some every-day use cases, if you think that one use case is missing and should be added, feel free to open an issue :)

### Basic use

[](#basic-use)

```
