Spaces:
Sleeping
Sleeping
Download packages/api/src/utils/logger.ts from projectsorg/ever-brain: direct link, hf CLI and curl.
- Browser
- Download file 1.93 kB
-
https://huggingface.co/spaces/projectsorg/ever-brain/resolve/main/packages/api/src/utils/logger.ts
- Command line
-
hf download hf://spaces/projectsorg/ever-brain/packages/api/src/utils/logger.ts
-
curl -L -o logger.ts https://huggingface.co/spaces/projectsorg/ever-brain/resolve/main/packages/api/src/utils/logger.ts
1.93 kB
| export function formatTimestamp(): string { | |
| const now = new Date(); | |
| const hours = String(now.getHours()).padStart(2, '0'); | |
| const minutes = String(now.getMinutes()).padStart(2, '0'); | |
| const seconds = String(now.getSeconds()).padStart(2, '0'); | |
| return `[${hours}:${minutes}:${seconds}]`; | |
| } | |
| export const logger = { | |
| info(tag: string, message: string): void { | |
| console.log(`${formatTimestamp()} โน๏ธ [${tag}] ${message}`); | |
| }, | |
| success(tag: string, message: string): void { | |
| console.log(`${formatTimestamp()} โ [${tag}] ${message}`); | |
| }, | |
| target(repo: string, branch: string): void { | |
| console.log(`${formatTimestamp()} ๐ฏ [Target] Parsed repo: ${repo} (Branch: ${branch})`); | |
| }, | |
| tree(fileCount: number, durationMs: number, skippedCount = 0): void { | |
| console.log( | |
| `${formatTimestamp()} ๐ณ [Tree Discovery] ${fileCount} files discovered in ${durationMs}ms (${skippedCount} ignored/binary skipped)` | |
| ); | |
| }, | |
| raw(path: string, status: number, sizeBytes: number, durationMs: number): void { | |
| const sizeKb = (sizeBytes / 1024).toFixed(1); | |
| console.log( | |
| `${formatTimestamp()} ๐ [Raw Stream] ${path} -> ${status} OK (${sizeKb} KB, ${durationMs}ms)` | |
| ); | |
| }, | |
| search(query: string, matchesCount: number, durationMs: number): void { | |
| console.log( | |
| `${formatTimestamp()} ๐ [Search] Query '${query}' -> ${matchesCount} matches in ${durationMs}ms` | |
| ); | |
| }, | |
| rateLimit(remaining: number, limit: number): void { | |
| const level = remaining < 10 ? 'โ ๏ธ' : '๐'; | |
| console.log(`${formatTimestamp()} ${level} [GitHub API] Rate limit remaining: ${remaining}/${limit}`); | |
| }, | |
| warn(tag: string, message: string): void { | |
| console.warn(`${formatTimestamp()} โ ๏ธ [${tag}] ${message}`); | |
| }, | |
| error(tag: string, message: string, error?: unknown): void { | |
| console.error(`${formatTimestamp()} โ [${tag}] ${message}`, error ? error : ''); | |
| }, | |
| }; | |