lily
    Preparing search index...

    Interface Transport

    a transport defines where log entries are sent. implement this interface to create custom log destinations.

    class HttpTransport implements Transport {
    constructor(private url: string) {}

    async log(entry: LogEntry): Promise<void> {
    await fetch(this.url, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(entry)
    });
    }
    }
    class DatabaseTransport implements Transport {
    async log(entry: LogEntry): Promise<void> {
    await db.logs.insert({
    level: entry.level,
    message: entry.message,
    timestamp: entry.timestamp,
    scope: entry.scope.join('/'),
    metadata: entry.metadata
    });
    }
    }
    interface Transport {
        log(entry: LogEntry): void | Promise<void>;
    }

    Implemented by

    Index

    Methods

    Methods

    • process a log entry. can be synchronous or asynchronous. if this method throws an error or returns a rejected promise, the error will be caught and logged to console.error.

      Parameters

      • entry: LogEntry

        the log entry to process

      Returns void | Promise<void>