Skip to content
This repository has been archived by the owner on Jun 20, 2021. It is now read-only.

Simple way to create instance of Monolog\Logger

Notifications You must be signed in to change notification settings

mikeevstropov/simple-logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mikeevstropov/simple-logger

Simple way to create instance of Monolog\Logger

Installation

Add dependency mikeevstropov/simple-logger

$ composer require mikeevstropov/simple-logger

Usage

<?php
  
use Mikeevstropov\SimpleLogger\LoggerFactory;

$logger = LoggerFactory::create(
    'path/to/file.log',
    'DEBUG',
    'log-name'
);

// add records to the log
$logger->warning('Warning message');
$logger->error('Error message');
// .. or other levels described by RFC 5424

LoggerFactory Interface

  • create

    Returns instance of Monolog\Logger

    Arguments:

    • file (string) - path to the log file
    • level (string) - log level or "DEBUG" as default
    • name (string) - name of logger or "logger" as default

    Returns:

    • Monolog\Logger

Log Levels

Monolog supports the logging levels described by RFC 5424.

  • DEBUG (100): Detailed debug information.

  • INFO (200): Interesting events. Examples: User logs in, SQL logs.

  • NOTICE (250): Normal but significant events.

  • WARNING (300): Exceptional occurrences that are not errors. Examples: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.

  • ERROR (400): Runtime errors that do not require immediate action but should typically be logged and monitored.

  • CRITICAL (500): Critical conditions. Example: Application component unavailable, unexpected exception.

  • ALERT (550): Action must be taken immediately. Example: Entire website down, database unavailable, etc. This should trigger the SMS alerts and wake you up.

  • EMERGENCY (600): Emergency: system is unusable.

Development

Clone

$ git clone https://github.com/mikeevstropov/simple-logger.git

Go to project

$ cd simple-logger

Install dependencies

$ composer install

Run the tests

$ composer test

About

Simple way to create instance of Monolog\Logger

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages