Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Generate text and images via the reverse-engineered Gemini Web API with multi-turn conversation support.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/gemini-webapi/utils/logger.ts
1export type LogLevel = 'TRACE' | 'DEBUG' | 'INFO' | 'WARNING' | 'ERROR' | 'CRITICAL' | number;23const lvl: Record<Exclude<LogLevel, number>, number> = {4TRACE: 0,5DEBUG: 1,6INFO: 2,7WARNING: 3,8ERROR: 4,9CRITICAL: 5,10};1112let cur = lvl.INFO;1314function toNum(level: LogLevel): number {15if (typeof level === 'number') return level;16return lvl[level] ?? lvl.INFO;17}1819export function set_log_level(level: LogLevel): void {20cur = toNum(level);21}2223export const setLogLevel = set_log_level;2425function emit(level: Exclude<LogLevel, number>, args: unknown[]): void {26if (lvl[level] < cur) return;27const prefix = `[gemini_webapi] ${level}:`;2829if (level === 'WARNING') console.warn(prefix, ...args);30else if (level === 'ERROR' || level === 'CRITICAL') console.error(prefix, ...args);31else console.log(prefix, ...args);32}3334export const logger = {35trace: (...args: unknown[]) => emit('TRACE', args),36debug: (...args: unknown[]) => emit('DEBUG', args),37info: (...args: unknown[]) => emit('INFO', args),38warning: (...args: unknown[]) => emit('WARNING', args),39error: (...args: unknown[]) => emit('ERROR', args),40success: (...args: unknown[]) => emit('INFO', args),41};4243