Skip to content

opxcore/log-interface

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Log interface

Build Status Coverage Status Latest Stable Version Total Downloads License

This is interface for the log used in OpxCore and basics for building PSR-3 loggers.

Installing

composer require opxcore/log-interface

Logger basics

LogException

OpxCore\Log\Exceptions\LogException::class is base for any logger exceptions. It extends Psr\Log\InvalidArgumentException for PSR-3 compatibility and should be used as is or as parent for any logger exceptions.

AbstractLogger

OpxCore\Log\AbstractLogger::class is abstract class implementing Psr\Log\LoggerInterface for PSR-3 compatibility.

AbstractLogger defines several common methods to be used in loggers:

  • formatMessage(string $level, string $message, array $context = []): string returns formatted interpolated message with log level and timestamp.

  • interpolateMessage(string $message, array $context): string interpolates the message with content. See PSR-3-logger-interface . If 'exception' key presents in context array and has any of Exception::class its stacktrace will be included to log message.

  • getTimestamp(): string returns current timestamp in ISO8601 format.

  • Log levels shorthands: emergency(), alert(), critical(), error(), warning(), notice(), info(), debug()

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages