- Supports logging to single file or rotating files, one for each day
- Supports sending emails (with SMTP if desired)
RawLog is available via Composer/Packagist.
Add "rawphp/raw-log": "0.*@dev"
to the require block in your composer.json and then run composer install
.
{
"require": {
"rawphp/raw-log": "0.*@dev"
}
}
You can also simply run the following from the command line:
composer require rawphp/raw-log "0.*@dev"
Alternatively, just copy the contents of the RawLog folder into somewhere that's in your PHP include_path
setting. If you don't speak git or just want a tarball, click the 'zip' button at the top of the page in GitHub.
<?php
use RawPHP\RawLog\Log;
// configuration
// email settings obviously not required if not using MailHandler
$config = array(
class => 'RawPHP\\RawLog\\Log',
debug => FALSE,
$handlers = array(
'standard_log' = array(
class => 'RawPHP\\RawLog\\Handlers\\FileHandler',
file => '/path/to/log.txt',
formatter => 'RawPHP\\RawLog\\Formatters\\ErrorLogFormatter',
level => 0, // debug
),
rotate_log = array(
class => 'RawPHP\\RawLog\\Handlers\\RotatingFileHandler',
file => '/path/to/rotate.txt',
formatter => 'RawPHP\\RawLog\\Formatters\\ErrorLogFormatter',
level => 2, // notice
),
mail = array(
class => 'RawPHP\\RawLog\\Handlers\\MailHandler',
formatter => 'RawPHP\\RawLog\\Formatters\\MailLogFormatter',
level => 4, // error
),
),
'from_email' => 'no-reply@rawphp.org', // default from email to use in log emails
'from_name' => 'RawPHP', // default from name to use in log emails
'to_address' => 'test@example.com', // default email address to use in log emails
'to_name' => 'RawPHP', // default name
'subject' => 'RawPHP Error Log Message', // log email subject line
'smtp' => array( 'auth' => TRUE ), // enable SMTP authentication
'smtp' => array( 'host' => 'smtp.gmail.com' ), // main and backup SMTP servers
'smtp' => array( 'username' => 'username' ), // SMTP username
'smtp' => array( 'password' => 'password' ), // SMTP password
'smtp' => array( 'security' => 'ssl' ), // Enable TLS encryption, 'ssl' also accepted
'smtp' => array( 'port' => '465' ), // SMTP port
);
// get new instance
$log = new Log( $config );
// use cases
$log->debug( 'message' );
$log->info( 'message' );
$log->notice( 'message' );
$log->warning( 'message' );
$log->error( 'message' );
$log->critical( 'message' );
$log->alert( 'message' );
$log->emergency( 'message' );
This package is licensed under the MIT. Read LICENSE for information on the software availability and distribution.
Please submit bug reports, suggestions and pull requests to the GitHub issue tracker.
- Removed Monolog dependency.
- Rebuilt log from scratch - inspired by Monolog features
- Updated to PHP 5.3.
- Replaced php array configuration with yaml
- Updated to work with the latest rawphp/rawbase package.
- Initial Code Commit