some more re-org + fixes
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 1m1s
All checks were successful
Deploy to Web Server flyer-crawler.projectium.com / deploy (push) Successful in 1m1s
This commit is contained in:
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user