ProtectedconstructorStaticdefaultDefault factory function to create LogEvent instances. Used in case it was not set before by the user.
ProtectedclearTo ensure when invoking clearInstance method in a sub-class it also clears (null) the last log event
+
StaticdefaultDefault factory function to create LogEvent instances. Used in case it was not set before by the user.
ProtectedclearTo ensure when invoking clearInstance method in a sub-class it also clears (null) the last log event
sent to the appender.
The last log event sent by the appender.
-Log a LogEvent or build a log event using a message string with event type, and if present, with extra fields.
+
The last log event sent by the appender.
+Log a LogEvent or build a log event using a message string with event type, and if present, with extra fields.
It implements both the log methods from the Appender interface,
since in Typescript doesn't allow you to overload methods with the same name but with different signatures.
LogEvent or message string.
// Example: Log an error message with a custom event type and extra fields.
const appender = new ConsoleAppender() // Assuming ConsoleAppender extends AbstractAppender
appender.log("An error occurred", LOG_EVENT.ERROR, { user: "dlealv", id: 42 })
// Example: Log a warning event directly.
const warningEvent = new LogEventImpl("This is a warning", LOG_EVENT.WARNING)
appender.log(warningEvent) // Directly log a LogEvent instance
-Protected AbstractsendSend the log event to the appropriate destination. +
Protected AbstractsendSend the log event to the appropriate destination. This method must be implemented by subclasses to define how the log event is sent. It is the final responsible for sending the log event to the appropriate destination (e.g., console, file, etc.).
The log event to be sent.
Optionalcontext: string(Optional) A string to provide additional context in case of an error.
ProtectedsetSet the last log event sent to the appender.
+ProtectedsetSet the last log event sent to the appender.
The log event to be sent.
Returns a string representation of the appender. It includes the class name, layout, log event factory, +
Returns a string representation of the appender. It includes the class name, layout, log event factory, so far this class doesn't have additional properties to show. Intended to be used by subclasses to provide information of the base class.
A string representation of the appender.
-StaticclearStaticclearStaticgetThe layout associated to all events. Used to format the log event before sending it to the appenders. +
StaticgetThe layout associated to all events. Used to format the log event before sending it to the appenders. If the layout was not set, it returns a default layout (lazy initialization). The layout is shared by all events and all appenders, so it is static.
StaticgetGets the log event factory function used to create LogEvent instances. If it was not set before, it returns the default factory function.
+
StaticgetGets the log event factory function used to create LogEvent instances. If it was not set before, it returns the default factory function.
The logEventFactory is shared by all events and all appenders, so it is static.
The log event factory function.
-StaticsetSets the layout associated to all events, the layout is assigned only if it was not set before.
+StaticsetSets the layout associated to all events, the layout is assigned only if it was not set before.
The layout to set.
StaticsetSets the log event factory function used to create LogEvent instances if it was not set before.
StaticsetSets the log event factory function used to create LogEvent instances if it was not set before.
A factory function to create LogEvent instances.
Must have the signature (message: string, eventType: LOG_EVENT) => LogEvent, i.e. LogEventFactory type.
If not provided, a default factory function is used.
// Example: Custom LogEvent to be used to specify the environment where the log event was created.
let prodLogEventFactory: LogEventFactory
= function prodLogEventFactoryFun(message: string, eventType: LOG_EVENT) {
return new LogEventImpl("PROD-" + message, eventType) // add environment prefix
}
AbstractAppender.setLogEventFactory(prodLogEventFactory) // Now all appenders will use ProdLogEvent
-
Constructs a new
-AbstractAppenderinstance. Nothing is initialized, because the class only has static properties that are lazy initialized or set by the user.