RequestLoggerCreator

namespace

bhenk\logger\build

predicates

Cloneable | Instantiable

implements

LoggerCreatorInterface

extends

AbstractLoggerCreator

hierarchy

RequestLoggerCreator -> AbstractLoggerCreator

Class capable of creating a request logger

The request logger outputs request properties to a file. Request properties are for instance

  • request url,

  • ip address of the client,

  • http_method,

  • server,

  • referrer,

  • client browser


Constants

RequestLoggerCreator::FILENAME

predicates

public

The default filename for a request logger

string(14) "logger/req.log"

RequestLoggerCreator::CHANNEL

predicates

public

The default channel for a request logger

string(3) "req"

RequestLoggerCreator::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

RequestLoggerCreator::create

predicates

public

implements

LoggerCreatorInterface::create

Creates a request logger

Optional param $paras have the format

[
  "channel" => "{string}",               // optional, default "req"
  "level" => Level,                      // optional, default Level::Debug
  "filename" => "{string}",              // optional, default self::FILENAME
  "max_files" => {int},                  // optional, default 2
  "filename_format" => "{string}",       // optional, default "{filename}-{date}"
  "filename_date_format" => "{string}",  // optional, default "Y-m"
  "line_format" => "{string}}"           // optional, default "%datetime% %extra%\n"
]

The optional filename may be relative to the ancestor log directory. @see LoggerCreatorInterface::LOG_DIR.

@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

see also

WebProcessor

public function create(
      Parameter #0 [ <optional> array $paras = [] ]
 ): Logger
param array $paras - see above
return Logger - a Logger that logs request properties in a file

RequestLoggerCreator::getFilename

predicates

public

Gets the absolute filename of the logfile

public function getFilename(): ?string
return ?string - the absolute filename of the logfile of the last logger created or null if a logger was not yet created

RequestLoggerCreator::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