Loggability::
LogDevice class
Superclass | Object |
An abstract base class for logging devices. A device manages the actual writing of messages to whatever destination logs are supposed to be shipped to, along with any buffering, encoding, or serialization that needs to be done.
Log devices are loadable by name via the ::create
method if they are declared in a directory named ‘loggability/log_device/` in the gem path.
Concrete log devices are required to implement two methods: write
and close
.
Takes one argument, which is the message that needs to be written.
Close any open filehandles or connections established by the device.
Constants
- DEVICE_TARGET_REGEX
Regexp used to split up logging devices in config lines
Public Class Methods
Requires the subclass and instantiates it with the passed-in arguments and then returns an instance of it.
Attempt to load a LogDevice
of the given type
.
Parses out the target class name and its arguments from the target_spec
then requires the subclass and instantiates it by passing the arguments. The target_spec
comes from a config file in the format of:
logging: datadog[data_dog_api_key]
In the above example:
-
“datadog” is the log device to send logs to
-
“data_dog_api_key” is the argument that will be passed onto the datadog log device’s constructor
Public Instance Methods
Close the device. This needs to be overridden by concrete subclasses; calling this implementation will raise an NotImplementedError.
Write a message
to the device. This needs to be overridden by concrete subclasses; calling this implementation will raise an NotImplementedError.