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

kiler129/ComposerPsr3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PROJECT ARCHIVED

While the code will (most likely) still work with Composer v1, this project is not maintained since 2016.


Composer PSR-3 Logger Build Status

Small, fast and PSR-3 compliant logging library useful with custom Composer scripts.

Requirements

  • PHP >=5.6

Installation

Add package to require-dev and use ;-)

Usage

Initialize Logger object in your Composer hook and optionally set custom verbosity levels - evetyhing else is automatic.

Available methods:

  • emergency/alert/...(message, context) - Every log level have method named after it. So if you want to log "warning" just use Logger->warning("Be warned!"). Second argument can be array with any information possible to represent as string by (formatted by print_r()).
  • log(level, message, context) - It have the same effect as methods described below, so calling Logger->log("warning", "Be warned!") produces the same result as example above.

Configuration

Logger comes preconfigured by default, but allows to configure almost anything. List below specifies configuration methods along with default values (specified in brackets).

  • setLineFormat(<%1$s> [%2$s] %3$s [%4$s] [%5$s]) - How line should be formated. You can use 6 modifiers:
    • %1$s - date
    • %2$s - log level (uppercased)
    • %3$s - message text
    • %4$s - context (formatted by print_r())
    • %1$d - unix timestamp
  • setDatetimeFormat(d.m.Y H:i:s) - It accepts any date() compliant format.
  • setLevelVerbosity(level, value) - In fact PSR-3 states custom log levels are forbidden, but this logger supports them. By default messages with custom level uses verbosity defined by IOInterface::NORMAL. This method allows setting custom one (and even change builtin levels verbosity, which is NOT recommended).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published