Download the PHP package folded/log without Composer
On this page you can find all versions of the php package folded/log. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package log
Short Description Log information to various channels for your web app.
License MIT
Informations about the package log
folded/log
Log information to various channels for your web app.
Summary
- About
- Features
- Requirements
- Installation
- Examples
- Version support
About
I created this package to simply setup Monolog, usable in any projects easily.
Folded is a constellation of packages to help you setting up a web app easily, using ready to plug in packages.
- folded/action: A way to organize your controllers for your web app.
- folded/config: Configuration utilities for your PHP web app.
- folded/crypt: Encrypt and decrypt strings for your web app.
- folded/exception: Various kind of exception to throw for your web app.
- folded/history: Manipulate the browser history for your web app.
- folded/http: HTTP utilities for your web app.
- folded/orm: An ORM for you web app.
- folded/session: Session functions for your web app.
- folded/request: Request utilities, including a request validator, for your PHP web app.
- folded/routing: Routing functions for your PHP web app.
- folded/view: View utilities for your PHP web app.
Features
- Uses monolog/monolog
- Can add multiple "write channels" (example: file, ...) to the same logger
- Supports the following channels:
- File (e.g. StreamHandler)
Requirements
- PHP version >= 7.4.0
- Composer installed
Installation
- 1. Install the package
- 2. Add the setup code
1. Install the package
In your root folder, run this command:
Examples
- 1. Log a debug message to a file
- 2. Add extra parameters when logging
- 3. Log by choosing your severity manually
- 4. Add another channel to the same logger
1. Create a file logger
In this example, we will create a file logger, and then we will log a debug information into our log file.
Note that if you want to avoid typos, you can use constants for defining the file channel.
For the moment, there is only one channel:
You can log various severities. Here is all the log methods available:
- addAlertLog
- addCriticalLog
- addDebugLog
- addEmergencyLog
- addErrorLog
- addInfoLog
- addNoticeLog
- addWarningLog
2. Add extra parameters when logging
In this example, we will push extra data as key-value pairs alongisde our log message.
3. Log by choosing your severity manually
In this example, we will use a addLog
function, which let us choose the severity using a string for more flexibility.
Note you can use severity constants provided by this library if you want to avoid typos:
Here is a complete list of severities you can use:
4. Add another channel to the same logger
In this example, our logger will log to 2 differents files.
Now, everytime you call a log method like addDebugLog()
, the log will be written in these two files.
This is very powerful when this library will be able to provide with different kind of channels, so you will be able to write both in a file and in your Syslog channel for example.
Version support
7.3 | 7.4 | 8.0 | |
---|---|---|---|
v0.1.0 | ❌ | ✔️ | ❓ |
v0.1.1 | ❌ | ✔️ | ❓ |