Expand description
Constructors§
Methods§
Source§collect(data: unknown, depth: number, path: (string | number)[]): unknown
collect(data: unknown, depth: number, path: (string | number)[]): unknown
Collects data recursively and truncates it if it exceeds the maximum depth. This method is called by the transform method. It can be overridden in derived classes to customize the data collection. The default implementation returns a JSON-serializable object.
Source§serialize(entry: LogEntry): string
serialize(entry: LogEntry): string
Serializes a log entry to a string. This method is called by the LogWriter.write method. It can be overridden in derived classes to customize the serialization. The default implementation returns a JSON string. You can override this method to format the log entry differently.
Example:
class MyLogWriter extends LogWriter {
protected override serialize(entry: LogEntry): string {
const log = this.transform(entry);
return `${log.timestamp} [${log.severity}] ${log.message}`;
}
}
Source§transform(entry: LogEntry): Record<string, unknown>
transform(entry: LogEntry): Record<string, unknown>
Transforms a log entry into a plain object. This method is called by the serialize method. It can be overridden in derived classes to customize the transformation. The default implementation returns a plain object with the log entry properties.
A log writer that writes log entries to the console. You can extend this class to implement custom log writers that write to files, databases, or other destinations.
Logger for Development
Google Cloud Logger