phrity/logger-console

1.0.0 2025-08-26 15:51 UTC

This package is not auto-updated.

Last update: 2025-08-27 15:41:17 UTC


README

Phrity Logger Console

Build Status

Phrity Logger Console

A PSR-3 compatible console logger. Useful when running local tests and various console applications.

Installation

Install with Composer;

composer require phrity/logger-console

Verbosity

Verbosity level can be set on the logger.

use Phrity\Logger\Console\{
    ConsoleLogger,
    Verbosity,
};
$logger = new ConsoleLogger(verbosity: Verbosity::Verbose);

Available levels (default: Verbosity::Normal);

  • Verbosity::Quiet
  • Verbosity::Normal
  • Verbosity::Verbose
  • Verbosity::VeryVerbose
  • Verbosity::Debug

Output format

Output format can be specified using string with replacers.

use Phrity\Logger\Console\ConsoleLogger;
$logger = new ConsoleLogger(format: '{datetime} {level} {message} - {context}');

Available replacers;

  • datetime - ISO datetime string
  • level - Log level string
  • message - Log message (interpolated)
  • context - String representation of context data

Default format is '{datetime} [{level}] {message}'.

CLI options

By enabling CLI options, verbosity can be set as console argument.

use Phrity\Logger\Console\ConsoleLogger;
$logger = new ConsoleLogger(cliOptions: true);

Available verbosity argument;

  • --quiet -q
  • --verbose=1 -v
  • --verbose=2 -vv
  • --verbose=3 -vvv --debug

Versions

Version PHP
1.0 ^8.1 Initial version