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
- Host: GitHub
- URL: https://github.com/parseword/logger
- Owner: parseword
- License: apache-2.0
- Created: 2019-01-25T22:49:36.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-01-26T01:16:46.000Z (almost 7 years ago)
- Last Synced: 2025-03-02T20:26:14.528Z (10 months ago)
- Topics: file-logger, logger, php7, singleton
- Language: PHP
- Size: 10.7 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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