AutoSkill Generic Winston Logger Service
Create a robust, scalable Winston logger service for Node.js projects with daily log rotation, environment-aware formatting, and proper object serialization to prevent [object Object] errors.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/generic-winston-logger-service" ~/.claude/skills/ecnu-icalk-autoskill-generic-winston-logger-service && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8/generic-winston-logger-service/SKILL.mdsource content
Generic Winston Logger Service
Create a robust, scalable Winston logger service for Node.js projects with daily log rotation, environment-aware formatting, and proper object serialization to prevent [object Object] errors.
Prompt
Role & Objective
Create a generic, robust, and scalable Winston logger service for Node.js applications. The logger must be reusable across projects and handle common logging issues like object serialization.
Operational Rules & Constraints
- Dependencies: Use
andwinston
.winston-daily-rotate-file - Transports: Configure both Console and DailyRotateFile transports.
- Log Format:
- Use
to capture metadata.winston.format.metadata() - Use ISO 8601 timestamps:
.YYYY-MM-DDTHH:mm:ssZ - Implement a custom
function that formats the log string.printf
- Use
- Object Serialization: Ensure that metadata objects and arrays are serialized using
to preventJSON.stringify(metadata, null, 2)
output.[object Object] - Environment Awareness:
- Check
.process.env.NODE_ENV === 'development' - Apply
to the console transport only in development.winston.format.colorize()
- Check
- Log Rotation:
- Rotate logs daily (
).datePattern: "YYYY-MM-DD" - Enable
.zippedArchive: true - Set
andmaxSize: "20m"
.maxFiles: "14d"
- Rotate logs daily (
- Exception Handling:
- Enable
andhandleExceptions: true
on transports.exitOnError: false - Listen for
events and log them using the logger.unhandledRejection
- Enable
- Parameters: The function should accept
,appName
(defaulting to current working directory), andlogPath
(defaulting to "info").logLevel
Anti-Patterns
- Do not use deprecated timestamp formats.
- Do not allow
in log output.[object Object] - Do not colorize logs in production environments.
Triggers
- create a generic logger
- winston logger service
- robust logging setup
- fix [object Object] in logs
- scalable logger configuration