noflash/composer_psr3

This package is abandoned and no longer maintained. No replacement package was suggested.

PSR-3 complaint logger for use with Composer IOInterface

dev-master / 1.0.x-dev 2021-02-04 04:16 UTC

This package is auto-updated.

Last update: 2021-03-04 04:33:44 UTC


README

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).