Spaces:
Paused
Paused
Download logger.js from qwen2api/token-consumer: direct link, hf CLI and curl.
- Browser
- Download file 752 Bytes
-
https://huggingface.co/spaces/qwen2api/token-consumer/resolve/main/logger.js
- Command line
-
hf download hf://spaces/qwen2api/token-consumer/logger.js
-
curl -L -o logger.js https://huggingface.co/spaces/qwen2api/token-consumer/resolve/main/logger.js
752 Bytes
| // Logger with environment variable control | |
| // LOG_LEVEL: debug, info, warn, error, none (default: info) | |
| const LOG_LEVELS = { debug: 0, info: 1, warn: 2, error: 3, none: 4 }; | |
| const currentLevel = LOG_LEVELS[process.env.LOG_LEVEL?.toLowerCase()] ?? LOG_LEVELS.info; | |
| const ts = () => new Date().toISOString(); | |
| const log = { | |
| debug: (...args) => currentLevel <= LOG_LEVELS.debug && console.log(`[${ts()}] [DEBUG]`, ...args), | |
| info: (...args) => currentLevel <= LOG_LEVELS.info && console.log(`[${ts()}] [INFO]`, ...args), | |
| warn: (...args) => currentLevel <= LOG_LEVELS.warn && console.warn(`[${ts()}] [WARN]`, ...args), | |
| error: (...args) => currentLevel <= LOG_LEVELS.error && console.error(`[${ts()}] [ERROR]`, ...args), | |
| }; | |
| module.exports = log; | |