some more re-org + fixes
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 1m1s

This commit is contained in:
2025-11-24 14:46:17 -08:00
parent ff2a82f06d
commit a4d5e95937
15 changed files with 109 additions and 31 deletions

View File

@@ -14,10 +14,14 @@ type LogLevel = 'INFO' | 'WARN' | 'ERROR' | 'DEBUG';
* methods. Using `unknown[]` is more type-safe than `any[]` and satisfies the linter.
*/
const log = <T extends unknown[]>(level: LogLevel, message: string, ...args: T) => {
const pid = process.pid;
// Check if `process` is available (Node.js) vs. browser environment.
// This makes the logger "isomorphic" and prevents runtime errors on the client.
const envIdentifier = typeof process !== 'undefined' && process.pid
? `PID:${process.pid}`
: 'BROWSER';
const timestamp = getTimestamp();
// We construct the log message with a timestamp, PID, and level for better context.
const logMessage = `[${timestamp}] [PID:${pid}] [${level}] ${message}`;
const logMessage = `[${timestamp}] [${envIdentifier}] [${level}] ${message}`;
switch (level) {
case 'INFO':