Transport
About
This class provides base functionality for Logger
transports. Each fully configured Logger
has one or more transports. TransportDelegate
classes do the actual work of logging, taking a log info
object and writing it somewhere. For example, ConsoleTransport
uses the LOG EVENT
command to write a log message to system outputs. You can write your own transport delegates to do whatever you want. For example, you could write log messages to a floating window, or email log messages of a certain level.
API
constructor()
cs.js.Transport.new(name : Text; delegate : 4D.Class { ; options : Object })
Creates a new transport with the given name that will delegate to delegate.
Once a transport is added to a logger, it may be retrieved by name. For example, if name is "email", this transport may be retrieved like so:
$transport:=$logger.transports.email
IMPORTANT
If you want to retrieve a transport by name, it is up to you to ensure that name is unique across all transports for a given logger.
options may contain the following properties:
.level
is a string which defines the level at or below which messages will be sent to this transport if they pass the level test in the parent logger. If not present or empty, the level is ignored..format
sets the.format
specific to this transport. If undefined or null, the parent logger’s format is used..delegateOptions
is an object that is passed to the transport delegate’s constructor. SeeTransportDelegate
for more information.
Example
$options:=New object()
$options.delegateOptions:=New object("path"; "/LOGS/mylog.log")
$transport:=cs.js.Transport.new(cs.FileTransport.name; cs.FileTransport; $options)
.format
.format : Object
.format := format : Object
Gets or sets the format
specific to this transport. If format is null, the parent logger’s format is used.
.level
.level : Text
.level := level : Text
Gets or sets the maximum level at which this transport will be invoked by the parent logger. If level is an empty string, this transport’s level is ignored by the parent logger. If level is not a valid log level name, nothing happens.
.name
.name : Text
Returns the name of this transport as provided to the constructor. This property is read-only.