Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Ratings | Unique User Downloads | Download Rankings | ||||
Not yet rated by the users | Total: 170 | All time: 8,841 This week: 94 |
Version | License | PHP version | Categories | |||
php-logger-lib 1.1.3 | MIT/X Consortium ... | 5.6 | PHP 5, Logging, PHP 7, PSR |
Description | Author | |
This package can log errors to files and display messages on a page. |
Php library to create logs easily and store them in Json format.
This library is supported by PHP versions 5.6 or higher and is compatible with HHVM versions 3.0 or higher.
The preferred way to install this extension is through Composer.
To install PHP Logger library, simply:
$ composer require Josantonius/Logger
The previous command will only install the necessary files, if you prefer to download the entire source code you can use:
$ composer require Josantonius/Logger --prefer-source
You can also clone the complete repository with Git:
$ git clone https://github.com/Josantonius/PHP-Logger.git
Or install it manually:
$ wget https://raw.githubusercontent.com/Josantonius/PHP-Logger/master/src/Logger.php
$ wget https://raw.githubusercontent.com/Josantonius/PHP-Json/master/src/Json.php
Available methods in this library:
new Logger($path, $filename, $logNumber, $ip, $states);
| Atttribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $path | Path name to save file with logs. | string | No | null | | $filename | JSON file name that will save the logs. | string | No | null | | $logNumber | Maximum number of logs to save to file. | int | No | 200 | | $ip | If you want to get to another library. | string | No | null | | $states | Different states for logs. | array | No | null |
# Return (void)
Logger::save($type, $code, $msg, $line, $file, $data);
| Atttribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $type | Error type or warning. | string | Yes | | | $code | HTTP response status code. | int | Yes | | | $message | Message. | string | Yes | | | $line | Line from which the save is executed. | int | Yes | | | $file | Filepath from which the method is called. | string | Yes | | | $data | Extra custom parameters. | array | No | 0 |
# Return (boolean)
Logger::store();
# Return (boolean)
Logger::get();
# Return (array) ? logs saved
Logger::script($url);
| Atttribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $url | File url. | string | Yes | |
# Return (string) ? file url
Logger::style($url);
| Atttribute | Description | Type | Required | Default | --- | --- | --- | --- | --- | | $url | File url. | string | Yes | |
# Return (string) ? file url
Logger::added();
# Return (int) ? logs added in the current section
Logger::render();
# Return (boolean true)
Logger::reset();
# Return (boolean true)
To use this library with Composer:
require __DIR__ . '/vendor/autoload.php';
use Josantonius\Logger\Logger;
Or If you installed it manually, use it:
require_once __DIR__ . '/Logger.php';
require_once __DIR__ . '/Json.php';
use Josantonius\Logger\Logger;
Example of use for this library:
<?php
require __DIR__ . '/vendor/autoload.php';
use Josantonius\Logger\Logger;
new Logger();
Logger::save('SUCCESS', 100, 'msg', __LINE__, __FILE__);
Logger::save('JOIN', 200, 'msg', __LINE__, __FILE__);
Logger::save('INFO', 300, 'msg', __LINE__, __FILE__);
Logger::save('WARNING', 400, 'msg', __LINE__, __FILE__);
Logger::save('ERROR', 500, 'msg', __LINE__, __FILE__);
Logger::save('FATAL', 600, 'msg', __LINE__, __FILE__);
Logger::save('REQUEST', 700, 'msg', __LINE__, __FILE__);
Logger::save('RESPONSE', 800, 'msg', __LINE__, __FILE__);
Logger::storeLogs();
<?php
require __DIR__ . '/vendor/autoload.php';
use Josantonius\Logger\Logger;
$states = [
'global' => true,
'exception' => true,
'error' => false,
'notice' => false,
'fatal' => true,
];
new Logger('/logger/', 'logs', 600, '58.80.84.44', $states);
Logger::save('EXCEPTION', 400, 'msg', __LINE__, __FILE__);
Logger::save('ERROR' , 402, 'msg', __LINE__, __FILE__);
Logger::save('NOTICE', 100, 'msg', __LINE__, __FILE__);
$params = [
'id-user' => 68,
'name-user' => 'Joe'
];
Logger::save('FATAL, 500, 'msg', __LINE__, __FILE__, $params);
Logger::storeLogs();
echo 'Logs added: ' . Logger::added();
echo 'Logs added: ' . count(Logger::get);
printf('<link href="%s">', Logger::style('http://site.com/public/css/'));
printf('<script src="%s">', Logger::script('http://site.com/public/js/'));
Logger::render();
To run tests you just need Composer and to execute the following:
$ git clone https://github.com/Josantonius/PHP-Logger.git
$ cd PHP-Logger
$ composer install
Run unit tests with PHPUnit:
$ composer phpunit
Run PSR2 code standard tests with PHPCS:
$ composer phpcs
Run all previous tests:
$ composer tests
This is intended for large and long-lived objects.
All files in this repository were created and uploaded automatically with Reposgit Creator.
This project is licensed under MIT license. See the LICENSE file for more info.
2017 Josantonius, josantonius.com
If you find it useful, let me know :wink:
Files (30) |
File | Role | Description | ||
---|---|---|---|---|
public (4 directories) | ||||
resources (5 files) | ||||
src (1 file) | ||||
tests (1 file) | ||||
.editorconfig | Data | Auxiliary data | ||
.travis.yml | Data | Auxiliary data | ||
CHANGELOG.md | Data | Auxiliary data | ||
composer.json | Data | Auxiliary data | ||
CONDUCT.md | Data | Auxiliary data | ||
contributors.txt | Doc. | Documentation | ||
gulpfile.js | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
package.json | Data | Auxiliary data | ||
phpcs.ruleset.xml | Data | Auxiliary data | ||
phpunit.xml.dist | Data | Auxiliary data | ||
README-ES.md | Doc. | Documentation | ||
README.md | Doc. | Documentation | ||
_config.yml | Data | Auxiliary data |
Files (30) | / | public |
Files (30) | / | public | / | css | / | source |
File | Role | Description |
---|---|---|
logger.css | Data | Auxiliary data |
logger.css.map | Data | Auxiliary data |
Files (30) | / | public | / | sass | / | partials |
File | Role | Description |
---|---|---|
_colors.sass | Data | Auxiliary data |
_global.sass | Data | Auxiliary data |
Files (30) | / | resources |
File | Role | Description |
---|---|---|
logger-1.png | Data | Auxiliary data |
logger-2.png | Data | Auxiliary data |
logger-3.png | Data | Auxiliary data |
logger-4.png | Data | Auxiliary data |
logger-5.png | Data | Auxiliary data |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.