2017 © Pedro Peláez
 

library logger

Wrapper for Monolog. Provides custom log levels with customized Handlers based on log level

image

cymapgt/logger

Wrapper for Monolog. Provides custom log levels with customized Handlers based on log level

  • Wednesday, July 4, 2018
  • by cymapgt
  • Repository
  • 1 Watchers
  • 1 Stars
  • 25 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 47 % Grown

The README.md

logger

Wrapper for Monolog library. Implements custom log levels out of the box. Based on the log importance, custom logger levels allow logging to file, email, sms or a combination of either /all, (*1)

Description

The logger package stands on the shoulders of giants; Monolog library is PHP's de facto logger which supports multiple channels, as well as building of custom channels, as has been done with the SmsChannel of the cymapgt logger. As such, most of the logger implementation is dedicated to configuration, with the heavy logging work being delegated to the elegant Monolog., (*2)

Installing

Install application via Composer

require "cymapgt/logger" : "^1.0.0"

Usage

Overview

The logger package implements the following Logger strategy:, (*3)

-Stderr Logger: This can be loaded in order to provide Stream Logging capability for CLI applications, (*4)

-Logger Level1: This application will provide basic logging services to just the default destination. The default destination for this logger is usually either a file or a database. As such, the log directory will have to be provided. Another option is database, but this is not implemented for now., (*5)

-Logger Level 2: This will still provide logging services to the log file as well as to email. It is utilized for log items that need more immediate attention., (*6)

-Logger Level 3: This will provide logging services to the log file, to email as well as to SMS. The idea behind the strategy is to enable graceful escalation in the event that an application may need to provide a more responsive log message by gradually choosing which log level to use., (*7)

-Logger Security: The security logger will provide security related logs to a separate secure file, (*8)

-Logger Alert: This is still in design, and is an escalated level of the Logger Security class, (*9)

Using the Logger package

Named Constants

//Log levels for Logger Class
if (!(defined('LOGGER_STDERR'))) {
    define('LOGGER_STDERR', 0);
}

if (!(defined('LOGGER_LEVEL1'))) {
    define('LOGGER_LEVEL1', 1);
}

if (!(defined('LOGGER_LEVEL2'))) {
    define('LOGGER_LEVEL2', 2);
}

if (!(defined('LOGGER_LEVEL3'))) {
    define('LOGGER_LEVEL3', 3);
}

if (!(defined('LOGGER_SECURITY'))) {
    define('LOGGER_SECURITY', 4);
}

Bootstraping the Logger

You need to have the bootstrap package, which you will use to set up the [logger] group configurations for this package in the file cymapgt.network.ini; for example., (*10)

See cymapgt/bootstrap documentation for how to run this configuration., (*11)

[logger]
logger_file_location = '/var/www/html/logger_test.txt'
logger_security_file_location = '/var/www/html/logger_security.txt'
logger_email_alert_administrators = '{"cogana@gmail.com": "Cyril Ogana"}'
logger_sms_alert_administrators = '254123456789'
logger_email_alert_subject = 'SYSTEM IMPORTANT LOG MESSAGE ALERT'
logger_email_security_alert_administrators = '{"cogana@gmail.com": "Cyril Ogana"}'
logger_sms_security_alert_administrators = '254123456789'
logger_email_security_alert_subject = 'SYSTEM IMPORTANT LOG MESSAGE ALERT'

Logging Example

use cymapgt\core\utility\bootstrap\Bootstrap;
use cymapgt\core\utility\logger\Logger;

$loggerDbError = Logger::getLogger(\LOGGER_SECURITY, Bootstrap::LoggerSecurityParams());
$loggerDbError->addError('Critical error, the core database is down'); //log to file, email and sms

Testing

PHPUnit Tests are provided with the package, (*12)

Contribute

  • Email @rhossis or contact via Skype
  • You will be added as author for contributions

License

BSD 3-clause, (*13)

The Versions

04/07 2018

dev-develop

dev-develop https://github.com/cymapgt/logger

Wrapper for Monolog. Provides custom log levels with customized Handlers based on log level

  Sources   Download

BSD-3-Clause BSD 3-Clause

The Requires

 

The Development Requires

monolog wrapper

04/07 2018

dev-master

9999999-dev https://github.com/cymapgt/logger

Wrapper for Monolog. Provides custom log levels with customized Handlers based on log level

  Sources   Download

BSD-3-Clause BSD 3-Clause

The Requires

 

The Development Requires

monolog wrapper

04/07 2018

2.0.2

2.0.2.0 https://github.com/cymapgt/logger

Wrapper for Monolog. Provides custom log levels with customized Handlers based on log level

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

monolog wrapper

04/07 2018

2.0.5

2.0.5.0 https://github.com/cymapgt/logger

Wrapper for Monolog. Provides custom log levels with customized Handlers based on log level

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

monolog wrapper

04/07 2018

2.0.1

2.0.1.0 https://github.com/cymapgt/logger

Wrapper for Monolog. Provides custom log levels with customized Handlers based on log level

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

monolog wrapper

23/04 2018

2.0.0

2.0.0.0 https://github.com/cymapgt/logger

Wrapper for Monolog. Provides custom log levels with customized Handlers based on log level

  Sources   Download

BSD 3-Clause

The Requires

 

The Development Requires

monolog wrapper

27/06 2017

1.0.4

1.0.4.0 https://github.com/cymapgt/logger

Wrapper for Monolog. Provides custom log levels with customized Handlers based on log level

  Sources   Download

BSD 3-Clause

The Requires

 

The Development Requires

monolog wrapper

03/01 2016

1.0.3

1.0.3.0 https://bitbucket.org/cymapgt/notifier/

Wrapper for Monolog. Provides custom log levels with customized Handlers based on log level

  Sources   Download

proprietary

The Requires

 

The Development Requires

monolog wrapper

25/10 2015

1.0.2

1.0.2.0 https://bitbucket.org/cymapgt/notifier/

Wrapper for Monolog. Provides custom log levels with customized Handlers based on log level

  Sources   Download

proprietary

The Requires

 

The Development Requires

monolog wrapper

26/06 2015

1.0.1

1.0.1.0 https://bitbucket.org/cymapgt/notifier/

Wrapper for Monolog. Provides custom log levels with customized Handlers based on log level

  Sources   Download

proprietary

The Requires

 

The Development Requires

monolog wrapper

21/05 2015

1.0.0

1.0.0.0 https://bitbucket.org/cymapgt/notifier/

Wrapper for Monolog. Provides custom log levels with customized Handlers based on log level

  Sources   Download

proprietary

The Requires

 

The Development Requires

monolog wrapper