\phpWTLExtendedLogger

Logger for the extended log file format (see: https://www.w3.org/TR/WD-logfile.html).

A logger in its basic form typically handles the following tasks:

- Instantiate a LoggerContent object and provide it with a format blueprint in form of a static FormatDescriptor class
- Initialize a DataRetriever and provide it with a LoggerContent object (and if applicable with RetrievalPolicies)
- Initialize a DataValidator and provide it with a LoggerContent object
- Initialize a DataFormatter and provide it with a LoggerContent object
- Provide a method to perform the actual logging (i.e. invoke retriever, validator and formatter accordingly)

Summary

Methods
Properties
Constants
log()
getDataRetrievalPolicies()
setDataRetrievalPolicies()
getFormatDescriptor()
getLoggerContent()
getDataRetriever()
getDataValidator()
getDataFormatter()
getInstance()
getBuffer()
takeTime()
timeTaken()
microtimeMilis()
buildDirectivesForFileWriter()
setDirectives()
No public properties found
No constants found
loadDataRetrievalPoliciesDefault()
__clone()
__sleep()
__wakeup()
__construct()
initializeBuffering()
finalizeBuffering()
getDirectives()
retrieveFieldsDirectiveContent()
$retrievalPolicies
$loggerContent
$dataRetriever
$dataValidator
$dataFormatter
$_instance
$time_taken_start
$time_taken_stop
N/A
No private methods found
No private properties found
N/A

Properties

$retrievalPolicies

$retrievalPolicies : 

Type

$loggerContent

$loggerContent : 

Type

$dataRetriever

$dataRetriever : 

Type

$dataValidator

$dataValidator : 

Type

$dataFormatter

$dataFormatter : 

Type

$_instance

$_instance : 

Array to hold instances of all derived classes.

Type

$time_taken_start

$time_taken_start : 

Type

$time_taken_stop

$time_taken_stop : 

Type

Methods

log()

log(array  $params = null) : array

Perform the actual logging process:

  • Handle buffer flush and buffer-size measurement for ContentLengthRetrieval policy
  • Handle stop timestamp measurement for time-taken field
  • Retrieve log data thru retriever
  • Validate data fields with validator (can be turned off)
  • Format/prefix/suffix fields via formatter (can be turned off), set the datatype class in content object accordingly

Parameters

array $params

Logger parameters (bool "validate" default "false", bool "format" default "true")

Returns

array —

Validation errors (null if none)

getDataRetrievalPolicies()

getDataRetrievalPolicies() : array

Return data retrieval policies set during initialization.

Returns

array

setDataRetrievalPolicies()

setDataRetrievalPolicies(array  $retrievalPolicies = null) 

Set data retrieval policies after initialization:

  • Also do this in the associated data retriever
  • If null restore the default
  • Handle buffer reset/initialization for ContentLengthRetrieval policy

Parameters

array $retrievalPolicies

Provide policies for data retrieval.

getFormatDescriptor()

getFormatDescriptor() 

getLoggerContent()

getLoggerContent() 

getDataRetriever()

getDataRetriever() 

getDataValidator()

getDataValidator() 

getDataFormatter()

getDataFormatter() 

getInstance()

getInstance(array|mixed|null  $inject = null) : \phpWTL\$_instance[$class]

Create new instance or give back already existing one.

Parameters

array|mixed|null $inject

Can be used to inject one or more parameter(s) into the constructor

Returns

\phpWTL\$_instance[$class] —

The instance of a derived class

getBuffer()

getBuffer() : string

Return PHP output buffer.

Returns

string —

buffer content (null if logging mode is not buffered)

takeTime()

takeTime(boolean  $stop = false) 

Handle time measurement.

Parameters

boolean $stop

Start or stop measurement (default= false= start).

timeTaken()

timeTaken() : \phpWTL\miliseconds.

Handle time measurement.

Returns

\phpWTL\miliseconds.

microtimeMilis()

microtimeMilis() : \phpWTL\miliseconds.

microtime float value.

Returns

\phpWTL\miliseconds.

buildDirectivesForFileWriter()

buildDirectivesForFileWriter(array  $fields_whitelist = null) : array

Build directives (meta data) content lines for a file writer

Parameters

array $fields_whitelist

If given two things will be done: a) only fields matching the list will be included in the "Fields" directive and b) they will be sorted according to the order of the whitelist.

Returns

array —

Lines

setDirectives()

setDirectives(array  $fields_whitelist = null) 

Set directives (meta data) array

Parameters

array $fields_whitelist

If given two things will be done: a) only fields matching the list will be included in the "Fields" directive and b) they will be sorted according to the order of the whitelist.

loadDataRetrievalPoliciesDefault()

loadDataRetrievalPoliciesDefault() 

Set default data retrieval policies.

__clone()

__clone() 

Disable cloning for singleton.

Throws

\phpWTL\Exception

if called

__sleep()

__sleep() 

Disable serialization for singleton.

Throws

\phpWTL\Exception

if called

__wakeup()

__wakeup() 

Disable de-serialization for singleton.

Throws

\phpWTL\Exception

if called

__construct()

__construct(object  $retrievalPolicies = null) 

The constructor must perform the following taks:

  • Call "loadRetrievalPolicies" or handle the policies otherwise appropriately
  • Instantiate and store a LoggerContent object based on the required static FormatDescriptor
  • Handle/store all other (optional) parts neccessary and/or wanted (data retriever, validator, formatter)
  • Handle buffer initialization for ContentLengthRetrieval policy
  • Handle start timestamp measurement for time-taken field

Parameters

object $retrievalPolicies

Provide policies for data retrieval (if applicable).

initializeBuffering()

initializeBuffering() 

Buffer initialization for ContentLengthRetrieval policy.

finalizeBuffering()

finalizeBuffering() 

Buffer finalization for ContentLengthRetrieval policy (flush, store content-length).

getDirectives()

getDirectives(array  $fields_whitelist = null) : array

Get directives (meta data) array

Parameters

array $fields_whitelist

If given two things will be done: a) only fields matching the list will be included in the "Fields" directive and b) they will be sorted according to the order of the whitelist.

Returns

array

retrieveFieldsDirectiveContent()

retrieveFieldsDirectiveContent(array  $fields_whitelist = null) : string

Return String for "Fields" Directive

Parameters

array $fields_whitelist

If given two things will be done: a) only fields matching the list will be included in the "Fields" directive and b) they will be sorted according to the order of the whitelist.

Returns

string