Skip to content

ALogger is fork KLogger and simple logging for PHP

License

Notifications You must be signed in to change notification settings

kozintsev/ALogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ALogger is fork KLogger and simple logging for PHP

A project forked and refactored Oleg Kozinsev.

About

All that relates to Klogger is also relevant for ALogger. But Alogger creates an instance of the object for saving every time it is saved, which allows you to delete the log file while you work. Also removed all options and added the ability to split the file into parts.

Composer

From the Command Line:

composer require kozintsev/a-logger:dev-master

In your composer.json:

{
    "require": {
        "kozintsev/a-logger": "dev-master"
    }
}

Basic Usage

<?php

require_once ("vendor/autoload.php");

use kozintsev\ALogger\Logger;

$logger = new Logger(__DIR__ . '/tests/logs/test.log', \Psr\Log\LogLevel::DEBUG);
$logger->info('Returned a million search results');
$logger->error('Oh dear.');
$logger->debug('Got these users from the Database.', $users);

Output

[2014-03-20 3:35:43.762437] [INFO] Returned a million search results
[2014-03-20 3:35:43.762578] [ERROR] Oh dear.
[2014-03-20 3:35:43.762795] [DEBUG] Got these users from the Database.
    0: array(
        'name' => 'Kenny Katzgrau',
        'username' => 'katzgrau',
    )
    1: array(
        'name' => 'Dan Horrigan',
        'username' => 'dhrrgn',
    )

Additional Options

ALogger supports additional options via third parameter in the constructor:

<?php
// Example
$logger = new kozintsev\ALogger\Logger(__DIR__ . '/tests/logs/test.log', Psr\Log\LogLevel::WARNING, [
    'max_file_size' => 0, // max file size, if set to 0, the size is not checked
]);

Here's the full list:

Option Default Description
max_file_size 5120000 the maximum size of the log file, if set to 0, the size is not checked

About

ALogger is fork KLogger and simple logging for PHP

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages