Download the PHP package zooxsmart/los-log without Composer
On this page you can find all versions of the php package zooxsmart/los-log. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zooxsmart/los-log
More information about zooxsmart/los-log
Files in zooxsmart/los-log
Package los-log
Short Description LosLog provides some log utility
License MIT
Homepage http://github.com/Lansoweb/LosLog
Informations about the package los-log
LosLog
Introduction
This is the 2.0 documentation version. Please refer to the README-1.0 for 1.0 documentation.
This module provides some useful log classes:
- LosLog = An error middleware for PSR-7 compatible frameworks/applications
- HttpLog = Use to log request and response from a PSR-7 application
- ErrorLogger = PHP error
- ExceptionLogger = PHP Exception
- StaticLogger = "Shortcut" to a generic file logger. Can be attached to the Z-Ray in Zend Server
- Rollbar writer = A Rollbar writer. Uploads errors and exceptions to Rollbar service
Requirements
- php >= 5.6.0
- laminas/laminas-stratigility
- laminas/laminas-diactoros
- laminas/laminas-log
Instalation
For composer documentation, please refer to getcomposer.org.
Usage
Copy the file loslog.global.php.dist to your config/autoload/ , rename it to loslog.global.php and change the default options, if needed.
LosLog Middleware
Zend Expressive
Expressive 2.0 introduced a new method to handle errors, using listeners to the ErrorHandler and delegator factories, so this is the preferable method.
Add the delegator factory to the ErrorHandler, like:
General use
If using other framework, you can add the LosLogFactory to your factory system, manually create a LosLog instance or call the LosLogFactory directly.
HttpLog Middleware
It will log requests and responses in compact or full mode. It will include X-Request-Id and X-Response-Time headers if present.
Zend Expressive
Add the middleware as the first middleware in your pipeline, like:
Set the desired options in loslog.global.php (or loslog.local.php):
You can integrate with los/request-id and los/response-time. The order is important, use as bellow:
This will produce:
ErrorLogger
To enable the ErrorLogger just add the registerHandlers inside your public/index.php
Zend Framework 2
Zend Expressive
You can use the logger with your phpunit tests. Just call it in your bootstrap file just after the autoload is created:
Output example
The default logfile is data/log/error.log
ExceptionLogger
To enable the ExceptionLogger just add the registerHandlers inside your public/index.php
Zend Framework 2
Zend Expressive
Output example
The default logfile is data/log/exception.log
StaticLogger
This logger is usually used to log development or debug messages, arrays and objects. Just call it statically anywhere in your code.
will generate
Or an object:
will generate
The default logfile is data/log/static.log
Z-Ray
Z-Ray is an awesome resource from Zend Server that provides several information about the request, errors and the framework. It also has the possibility to add your own informations, so i added the StaticLogger messages to it.
More information can be seen here.
Installation
The LosLog module is available via the Official Z-Ray plugin system, just access the tab from your Zend Server UI and install it.
Usage
Just use the StaticLogger and the messages will appear inside a LosLog section of the Z-Ray bar.
Optionally, you can pass a "null" value to the file argument to use just the Z-Ray, without writing the message to a file:
All versions of los-log with dependencies
psr/log Version ^1.0
laminas/laminas-stratigility Version ^3.11
laminas/laminas-diactoros Version ^3.3
laminas/laminas-log Version ^2.17
psr/container Version ^1.0 || ^2.0