\phpWTLLoggerContent

Representation of the content of a single log entry/log event.

This is a generic container class to store the field contents of a single logger entry. Instances of this class use dynamic getters and setters to deal with variable logging formats. This container is capable of character encoding.

Summary

Methods
Properties
Constants
__construct()
getFormatDescriptor()
getFieldDelimiter()
setFieldDelimiter()
getDatatypeClass()
setDatatypeClass()
getEncoding()
setEncoding()
getEncodingAssumption()
setEncodingAssumption()
getEncodingDetectionOrder()
setEncodingDetectionOrder()
probeFieldEncoding()
setFieldEncoding()
straightenUpEncodingAll()
__set()
__get()
__toString()
toString()
toStringMeta()
toArrayTyped()
toArrayTypedTrimmed()
toArrayTypedMeta()
toArrayTypedMetaTrimmed()
toArray()
toArrayTrimmed()
toArrayMeta()
sortArray()
getFieldContentTrimmed()
fieldNames2Captions()
No public properties found
No constants found
toArrayComplex()
$_encoding
$_encoding_assumption
$_encoding_detection_order
$_datatype_class
$_field_delimiter
$_format_descriptor
$_allowed_attributes
N/A
No private methods found
No private properties found
N/A

Properties

$_encoding

$_encoding : 

encoding

Type

$_encoding_assumption

$_encoding_assumption : 

encoding assumption

Type

$_encoding_detection_order

$_encoding_detection_order : 

encoding detection order

Type

$_datatype_class

$_datatype_class : 

datatype given (raw or formatted)

Type

$_field_delimiter

$_field_delimiter : 

standard delimiter for toString methods

Type

$_format_descriptor

$_format_descriptor : 

store the format description object

Type

$_allowed_attributes

$_allowed_attributes : 

Store allowed field IDs

Type

Methods

__construct()

__construct(object  $format_descriptor, array  $params = null) 

Parameters

object $format_descriptor

Provide a format descriptor class as the format blueprint.

array $params

Provide parameter array ("field_delimiter", "encoding", "encoding_assumption, "encoding_detection_order")

getFormatDescriptor()

getFormatDescriptor() : object

Returns

object —

Get the format descriptor class this LoggerContent object was built upon.

getFieldDelimiter()

getFieldDelimiter() : string

Returns

string —

Get the log field delimiter.

setFieldDelimiter()

setFieldDelimiter(string  $delimiter = "") 

Parameters

string $delimiter

Set the log field delimiter.

getDatatypeClass()

getDatatypeClass() : string

Returns

string —

Get the datatype class setting.

setDatatypeClass()

setDatatypeClass(integer  $datatype_class = null) 

Parameters

integer $datatype_class

Set the datatype class.

getEncoding()

getEncoding() : string

Returns

string —

Get the encoding setting.

setEncoding()

setEncoding(string  $encoding = "") 

Parameters

string $encoding

Set the character encoding (null or empty to disable encoding).

getEncodingAssumption()

getEncodingAssumption() : string

Returns

string —

Get the encoding assumption.

setEncodingAssumption()

setEncodingAssumption(string  $encoding_assumption = "") 

Parameters

string $encoding_assumption

Set the character encoding assumption.

getEncodingDetectionOrder()

getEncodingDetectionOrder() : string

Returns

string —

Get the encoding detection order.

setEncodingDetectionOrder()

setEncodingDetectionOrder(  $order = null) 

Parameters

$order

probeFieldEncoding()

probeFieldEncoding(string  $key) : string

Helper method to try to detect the encoding for a given format field

Parameters

string $key

Name of attribute (format field).

Returns

string

setFieldEncoding()

setFieldEncoding(string  $key, string  $encoding_assumption, string  $encoding) 

Helper method to set the encoding for a given format field

Parameters

string $key

Name of attribute (format field).

string $encoding_assumption

The character encoding assumption/strategy.

string $encoding

Character encoding.

straightenUpEncodingAll()

straightenUpEncodingAll(string  $encoding_assumption, string  $encoding) 

Helper method to set specific encoding for all attributes

Parameters

string $encoding_assumption

The character encoding assumption/strategy.

string $encoding

Character encoding.

__set()

__set(string  $key, string  $value) 

Dynamic setter.

Parameters

string $key

Name of attribute (format field) to set.

string $value

Value for attribute (format field) to set.

__get()

__get(string  $key) : string

Dynamic getter.

Parameters

string $key

Name of attribute (format field).

Returns

string —

Value of given attribute (format field).

__toString()

__toString() : string

String representation of the log-entry content, all default fields, no meta fields, separated by the line delimiter (this is a typical logfile line).

Returns

string

toString()

toString(array  $whitelist = null) : string

String representation of the log-entry content, regular (non-meta) fields according to whiteliste parameter, separated by the line delimiter (this is a typical logfile line).

Parameters

array $whitelist

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

Returns

string

toStringMeta()

toStringMeta(array  $whitelist = null) : string

String representation of the log-entry content meta fields according to whiteliste parameter, separated by the line delimiter.

Parameters

array $whitelist

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

Returns

string

toArrayTyped()

toArrayTyped(array  $whitelist = null) : array

Associative array representation of the regular (non-meta) log-entry content.

Parameters

array $whitelist

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

Returns

array

toArrayTypedTrimmed()

toArrayTypedTrimmed(array  $whitelist = null) : array

Associative array representation of the regular (non-meta) log-entry content.

Parameters

array $whitelist

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

Returns

array

toArrayTypedMeta()

toArrayTypedMeta(array  $whitelist = null) : array

Associative array representation of the regular (non-meta) log-entry content.

Parameters

array $whitelist

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

Returns

array

toArrayTypedMetaTrimmed()

toArrayTypedMetaTrimmed(array  $whitelist = null) : array

Associative array representation of the regular (non-meta) log-entry content.

Parameters

array $whitelist

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

Returns

array

toArray()

toArray(array  $whitelist = null) : array

Associative array representation of the regular (non-meta) log-entry content.

Parameters

array $whitelist

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

Returns

array

toArrayTrimmed()

toArrayTrimmed(array  $whitelist = null) : array

Associative array representation of the regular (non-meta) log-entry content, prefix+suffix trimmed.

Parameters

array $whitelist

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

Returns

array

toArrayMeta()

toArrayMeta(array  $whitelist = null) : array

Associative array representation of the log-entry meta content.

Parameters

array $whitelist

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

Returns

array

sortArray()

sortArray(array  $arrayToSort, array  $arrayToSortBy) : array

Sort an (associative) array by a sequence defined in another array.

Parameters

array $arrayToSort
array $arrayToSortBy

Returns

array

getFieldContentTrimmed()

getFieldContentTrimmed(string  $field_name) : string

Helper method to strip prefix/suffix from log field content.

Parameters

string $field_name

ID of log format field.

Returns

string —

Trimmed field content

fieldNames2Captions()

fieldNames2Captions(array  $contentArray) : array

Helper method to replace field names (IDs) with their captions for a given content array

Parameters

array $contentArray

Returns

array

toArrayComplex()

toArrayComplex(array  $whitelist, boolean  $trimmed, boolean  $meta) : array

Internal helper method for "toArrayTyped", "toArrayTypedMeta", "toArrayTypedTrimmed" and "toArrayTypedMetaTrimmed"

Parameters

array $whitelist

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

boolean $trimmed

Call "toArrayTrimmed" or check if $meta is set and...

boolean $meta

Call "toArrayMeta" or just "toArray"

Returns

array