\phpWTLCommonLogger

Logger for the NCSA common log format (see: https://en.wikipedia.org/wiki/Common_Log_Format).

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()
No public properties found
No constants found
loadDataRetrievalPoliciesDefault()
__clone()
__sleep()
__wakeup()
__construct()
initializeBuffering()
finalizeBuffering()
$retrievalPolicies
$loggerContent
$dataRetriever
$dataValidator
$dataFormatter
$_instance
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

Methods

log()

log(array  $params = null) : array

Perform the actual logging process:

  • Handle buffer flush and buffer-size measurement for ContentLengthRetrieval policy
  • 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

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)

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

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).