JSLogBuilder
Overview
The JSLogBuilder
class facilitates constructing and logging events with support for exceptions and parameterized messages. It integrates with the logging framework and is instantiated through JSLogger
methods. The class supports adding exceptions to log events, including Throwable
and JavaScript's NativeError
. Developers can log messages with or without additional parameters, using flexible formatting. When handling NativeError
objects, it extracts properties like name, message, and stack trace for inclusion in the log. Additionally, it provides functionality to log events without a message, making it suitable for error-only logging scenarios. The logging level is preserved as part of the instance for potential configuration or usage.
Methods Summarized
Methods Detailed
log()
Logs an event without adding a message. This can be useful in combination with withException(e) if no message is required.
Returns: void
Sample
log(message, params)
Logs a message with or without parameters.
Parameters
Object message the message to log; the format depends on the message factory.
Array params parameters to the message.
Returns: void
Sample
withException(exception)
Includes an exception in the log event.
Parameters
Object exception The exception to log.
Returns: JSLogBuilder the LogBuilder.
Sample
Last updated