@hacksaw/hono-google-cloud-logging
Version:
Google Cloud Logging Middleware for Hono
64 lines (63 loc) • 1.8 kB
TypeScript
export interface LoggerOptions {
/**
* Name of the log to write to
*/
name: string;
/**
* Optional resource to associate with the log
*/
resource?: {
type: string;
[key: string]: string;
};
/**
* Optional labels to include with every log entry
*/
labels?: Record<string, string>;
/**
* Optional filter function to determine if this logger should log the request
* @param path The request path
* @returns boolean indicating if this logger should log the request
*/
filter?: (path: string) => boolean;
}
export interface CloudLoggingOptions {
/**
* Project ID for Google Cloud
* If not provided, will be auto-detected from the environment
*/
projectId?: string;
/**
* Whether to log request bodies
* @default false
*/
logRequestBody?: boolean;
/**
* Whether to log response bodies
* @default false
*/
logResponseBody?: boolean;
/**
* Maximum size (in bytes) of request/response bodies to log
* @default 10240 (10KB)
*/
maxBodySize?: number;
/**
* Log severity level
* @default 'DEFAULT'
*/
severity?: "DEFAULT" | "DEBUG" | "INFO" | "NOTICE" | "WARNING" | "ERROR" | "CRITICAL" | "ALERT" | "EMERGENCY";
/**
* Development mode - logs to console instead of Google Cloud Logging
* @default false
*/
dev?: boolean;
}
/**
* Creates a Hono middleware for Google Cloud Logging
*
* @param loggerConfigs Array of logger configurations
* @param options Global options for all loggers
* @returns Hono middleware handler
*/
export declare const logger: (loggerConfigs: LoggerOptions[], options?: CloudLoggingOptions) => import("hono").MiddlewareHandler<any, string, {}>;