officescripts-logging-framework
    Preparing search index...

    Interface Appender

    Interface for all appenders (log destinations). An appender delivers log events to a specific output channel (e.g., console, Excel, file, remote service).

    • Implementations must provide both:
      • Structured logging via log(event: LogEvent)
      • Convenience logging via log(msg: string, event: LOG_EVENT)
    • Appenders are responsible for sending log events, not formatting (core formatting is handled by the Layout interface).
    • Implementations should be stateless or minimize instance state except for tracking the last sent event.
    • Common formatting and event creation concerns (such as layout or log event factory) are handled by the AbstractAppender base class and are not part of the interface contract.
    • getLastLogEvent() is primarily for diagnostics, testing, or error reporting.
    • toString() must return diagnostic information about the appender and its last log event.
    • Provides to log methods sending a LogEvent object or a message with an event type and optional extra fields. This allows flexibility in how log events are created and sent.
    • AbstractAppender for a base class that implements this interface.
    • LogEvent for the structure of log events.
    • Layout for the layout used to format log events before sending them to appenders.
    • LOG_EVENT for the enumeration of log event types.
    interface Appender {
        getLastLogEvent(): LogEvent;
        log(event: LogEvent): void;
        log(msg: string, type: LOG_EVENT, extraFields?: object): void;
        toString(): string;
    }

    Implemented by

    Index

    Methods

    • Returns the last LogEvent delivered to the appender, or null if none sent yet.

      Returns LogEvent

      The last LogEvent object delivered, or null.

      ScriptError if the appender instance is unavailable.

    • Sends a structured log event to the appender.

      Parameters

      • event: LogEvent

        The log event object to deliver.

      Returns void

      ScriptError if the event is invalid or cannot be delivered.

    • Sends a log message to the appender, specifying the event type and optional structured extra fields.

      Parameters

      • msg: string

        The message to log.

      • type: LOG_EVENT

        The type of log event (from LOG_EVENT enum).

      • OptionalextraFields: object

        Optional structured data (object) to attach to the log event (e.g., context info, tags).

      Returns void

      ScriptError if the log message is invalid or cannot be delivered.

    • Returns a string summary of the appender's state, typically including its type and last event.

      Returns string

      A string describing the appender and its most recent activity.

      ScriptError if the appender instance is unavailable.