DefaultLoggerCreator

namespace

bhenk\logger\build

predicates

Cloneable | Instantiable

implements

LoggerCreatorInterface

extends

AbstractLoggerCreator

hierarchy

DefaultLoggerCreator -> AbstractLoggerCreator

Class capable of creating a default logger

The default logger logs standard log messages to a logfile. Log messages exceeding a certain level will also be logged to an error logfile.


Constants

DefaultLoggerCreator::LOG_FILENAME

predicates

public

Default logfile

string(17) "logger/logger.log"

DefaultLoggerCreator::LOG_MAX_FILES

predicates

public

Default max logfiles to keep around

int(5)

DefaultLoggerCreator::LOG_LEVEL

predicates

public

Default log level

enum(Monolog\Level::Info)

DefaultLoggerCreator::FORMAT

predicates

public

Format for log entries

string(58) "%level_name% | %datetime% | %message% | %context% %extra% "

DefaultLoggerCreator::DATE_FORMAT

predicates

public

Date format in log entries

string(11) "Y-m-d H:i:s"

DefaultLoggerCreator::INTROSPECTION_PROCESSOR

predicates

public

Add an IntrospectionProcessor

bool(true)

DefaultLoggerCreator::ERR_FILENAME

predicates

public

Default error filename

string(16) "logger/error.log"

DefaultLoggerCreator::ERR_MAX_FILES

predicates

public

Default max error files to keep around

int(5)

DefaultLoggerCreator::ERR_LEVEL

predicates

public

Default error level

enum(Monolog\Level::Error)

DefaultLoggerCreator::DEFAULT_CHANNEL

predicates

public

Default channel name

string(3) "log"

DefaultLoggerCreator::LOG_DIR

predicates

public

Inherited from

LoggerCreatorInterface::LOG_DIR

Name of an ancestor child directory expected to be dedicated for logfiles

string(4) "logs"

Methods

DefaultLoggerCreator::create

predicates

public

implements

LoggerCreatorInterface::create

Creates a default logger

Optional param $paras have the format

[
   "channel" => "{string}",
   "log_file" => "{string}",
   "log_max_files" => {int},
   "log_level" => Level|LogLevel|string|int,
   "err_file" => "{string}",
   "err_max_files" => {int},
   "err_level" => Level|LogLevel|string|int,
   "format" => "{string}",
   "date_format" => "{string}",
   "introspection" => {bool},
]

@inheritdoc

Creates a logger that implements LoggerInterface

param array $paras - array of name-value pairs needed for building the logger.

@inheritdoc from method LoggerCreatorInterface::create

public function create(
      Parameter #0 [ <optional> array $paras = [] ]
 ): Logger
param array $paras
return Logger

DefaultLoggerCreator::makeAbsolute

predicates

public

inherited from

AbstractLoggerCreator::makeAbsolute

Tries to make the given filename absolute

An absolute param $filename will be returned as such.

This method will than try to locate an ancestor directory with a child with the name specified by LoggerCreatorInterface::LOG_DIR (logs). The returned absolute filename will than point to a child of this ancestor-child directory.

A param $filename is invalid if it is the empty string (“”) or the slash forward (/).

public function makeAbsolute(
      Parameter #0 [ <required> string $filename ]
 ): string
param string $filename - absolute or relative to ancestor directory ‘logs’
return string - absolute filename

Sat, 29 Apr 2023 12:38:18 +0000