An open API service indexing awesome lists of open source software.

https://github.com/parseword/logger

A PHP class implementing a singleton text file logging facility
https://github.com/parseword/logger

file-logger logger php7 singleton

Last synced: 6 months ago
JSON representation

A PHP class implementing a singleton text file logging facility

Awesome Lists containing this project

README

          

# Logger

Logger is a PHP text file logging facility, implemented as a singleton. It's
nothing special, but I'm breaking a larger code base down into independent
components and I needed this to be in its own repository.

## Usage

Implementing `Logger` in 4 easy steps:

1. Either `composer require parseword/logger` or copy the `Logger.php` file into
your project.

2. Make sure `Logger.php` is discoverable by your autoloader, or `require_once`
it manually.

3. Throughout your application code, call `Logger::debug()`, `Logger::info()`,
`Logger::warning()` and `Logger::error()` to send log messages of differing
severity levels.

4. In your application's config file or a common include file, you (or the user)
call Logger::setFilename() to set the log file, and Logger::setSeverityFilter()
to specify which log messages are written to disk.

## Example

In the following example, a file named `/tmp/my.log` is created. The severity
filter is set so that only messages with severity of WARNING or higher will be
written. Messages with lower severity will be disregarded.

```php