StreamLogTarget ​
- Type
- Class
- Namespace
- craft\log
- Inherits
- craft\log\StreamLogTarget » yii\log\Target » yii\base\Component » yii\base\BaseObject
- Implements
- yii\base\Configurable
- Uses traits
- craft\base\LogTargetTrait
- Since
- 3.6.0
Class StreamLogTarget
Public Properties ​
| Property | Description |
|---|---|
| behaviors | yii\base\Behavior – List of behaviors attached to this component. |
| categories | array – List of message categories that this target is interested in. |
| disableTimestamp | boolean – Whether to disable the timestamp. |
| enableLocking | boolean – Whether to use flock() to lock/unlock the stream before/after writing. |
| enabled | boolean – Indicates whether this log target is enabled. |
| except | array – List of message categories that this target is NOT interested in. |
| exportInterval | integer – How many messages should be accumulated before they are exported. |
| includeUserIp | boolean – Whether the user IP should be included in the default log prefix. |
| levels | integer – The message levels that this target is interested in. |
| logVars | array – List of the PHP predefined variables that should be logged in a message. |
| maskVars | array – List of the PHP predefined variables that should NOT be logged "as is" and should always be replaced with a mask *** before logging, when exist. |
| messages | array – The messages that are retrieved from the logger so far by this log target. |
| microtime | boolean – Whether to log time with microseconds. |
| prefix | callable, null – A PHP callable that returns a string to be prefixed to every exported message. |
| prefixString | string – A string to prepend to all messages. |
| replaceNewline | string, null – A string that should replace all newline characters in a log message. |
| url | string – The URL to use. |
disableTimestamp ​
- Type
- boolean
- Default value
false
Whether to disable the timestamp. The default is false which will prepend every message with a timestamp created with [yii\log\Target::getTime()].
enableLocking ​
- Type
- boolean
- Default value
false
Whether to use flock() to lock/unlock the stream before/after writing. This can be used to ensure that the stream is written by 2 processes simultaneously. Note though, that not all stream types support locking. The default is false.
prefixString ​
- Type
- string
- Default value
''
A string to prepend to all messages. The string will be added to the very beginning (even before the timestamp).
replaceNewline ​
A string that should replace all newline characters in a log message. Default is null for no replacement.
url ​
- Type
- string
- Default value
null
The URL to use. See https://php.net/manual/en/wrappers.php for details. This gets ignored if fp is configured.
Protected Properties ​
| Property | Description |
|---|---|
| fp | |
| openedFp | boolean |
fp ​
- Default value
null
openedFp ​
- Type
- boolean
- Default value
false
Public Methods ​
| Method | Description |
|---|---|
| __call() | Calls the named method which is not a class method. |
| __clone() | This method is called after the object is created by cloning an existing one. |
| __construct() | Constructor. |
| __destruct() | |
| __get() | Returns the value of a component property. |
| __isset() | Checks if a property is set, i.e. defined and not null. |
| __set() | Sets the value of a component property. |
| __unset() | Sets a component property to be null. |
| attachBehavior() | Attaches a behavior to this component. |
| attachBehaviors() | Attaches a list of behaviors to the component. |
| behaviors() | Returns a list of behaviors that this component should behave as. |
| canGetProperty() | Returns a value indicating whether a property can be read. |
| canSetProperty() | Returns a value indicating whether a property can be set. |
| className() | Returns the fully qualified name of this class. |
| closeFp() | Close the file handle if it was opened by this class |
| collect() | Processes the given log messages. |
| detachBehavior() | Detaches a behavior from the component. |
| detachBehaviors() | Detaches all behaviors from the component. |
| ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. |
| export() | Writes a log message to the given target URL |
| filterMessages() | Filters the given messages according to their categories and levels. |
| formatMessage() | Formats a log message for display as a string. |
| getBehavior() | Returns the named behavior object. |
| getBehaviors() | Returns all behaviors attached to this component. |
| getEnabled() | Check whether the log target is enabled. |
| getFp() | |
| getLevels() | |
| getMessagePrefix() | Returns a string to be prefixed to the given message. |
| hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. |
| hasMethod() | Returns a value indicating whether a method is defined. |
| hasProperty() | Returns a value indicating whether a property is defined for this component. |
| init() | Initializes the object. |
| off() | Detaches an existing event handler from this component. |
| on() | Attaches an event handler to an event. |
| setEnabled() | Sets a value indicating whether this log target is enabled. |
| setFp() | |
| setLevels() | Sets the message levels that this target is interested in. |
| trigger() | Triggers an event. |
__destruct() ​
closeFp() ​
Close the file handle if it was opened by this class
export() ​
Writes a log message to the given target URL
Throws ​
- yii\base\InvalidConfigException
If unable to open the stream for writing - yii\log\LogRuntimeException
If unable to write to the log
formatMessage() ​
Formats a log message for display as a string.
Arguments ​
$message(array) – The log message to be formatted. The message structure follows that in yii\log\Logger::$messages.
Returns ​
string – The formatted message
getFp() ​
Returns ​
resource – The stream resource to write messages to
Throws ​
init() ​
Initializes the object.
This method is invoked at the end of the constructor after the object is initialized with the given configuration.
setFp() ​
Arguments ​
$value(resource) – An open and writeable resource. This can also be one of PHP's pre-defined resources likeSTDINorSTDERR, which are available in CLI context.
Throws ​
Protected Methods ​
| Method | Description |
|---|---|
| getContextMessage() | Generates the context information to be logged. |
| getTime() | Returns formatted ('Y-m-d H:i:s') timestamp for message. |
getTime() ​
Returns formatted ('Y-m-d H:i:s') timestamp for message.
If microtime is configured to true it will return format 'Y-m-d H:i:s.u'.
Arguments ​
$timestamp(float)