phore/log

Logging class

v1.1.0 2020-09-09 09:19 UTC

This package is auto-updated.

Last update: 2020-09-18 11:11:08 UTC


README

Actions Status

  • PSR-3 compliant logger
  • Multiple targets (syslog, file, pipe) with individual configuration
  • Quick configuration with single uri
  • Multi-format support

Installation

composer require phore/log

Logger Usage

Easy usage

phore_Log("Some log message"); // Debug message
phore_log("Value :val expected", ["val"=>"some unescaped value"]); // Auto escaping
phore_log()->emergency("Emergency Message");

Configuration

Global configuration

PhoreLogger::Register(PhoreLoggerFactory::BuildFromUri("syslog+udp://metrics.host.tld:4200?tag=server1"));

Multi instance

$logger = PhoreLoggerFactory::BuildFromUri();

Logging

phore_log("something to log :message", ["message"=>"Hello"]);

phore_log()->setLogLevel(LogLevel::DEBUG);
phore_log()->emergency("emergency"); 

LogLevel

LogLevel Code
LogLevel::EMERGENCY 0
LogLevel::ALERT 1
LogLevel::CRITICAL 2
LogLevel::ERROR 3
LogLevel::WARNING 4
LogLevel::NOTICE 5
LogLevel::INFO 6
LogLevel::DEBUG 7 (default)

Logging configuration

You can specify one or more logger with different log levels.

syslog+udp://<hostname>:<port>/<tag>?severity=4&
syslogng+udp://
def://stdout?severity=4
def://stderr?severity=4
file:///var/log/xy.log?severity=4