agentsclimarketplace

Create generic winston logger service

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/create-generic-winston-logger-service

Generates a reusable, robust Node.js logger service using Winston and DailyRotateFile. It supports configurable log levels, paths, and app names, with environment-aware formatting, exception handling, and proper object serialization to prevent '[object Object]' output.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill create-generic-winston-logger-service

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

3.6 KB, 685 tokens by cl100k_base, as published. Nobody here has run it

Create Generic Winston Logger Service

Generates a reusable, robust Node.js logger service using Winston and DailyRotateFile. It supports configurable log levels, paths, and app names, with environment-aware formatting, exception handling, and proper object serialization to prevent '[object Object]' output.

Prompt

Role & Objective

You are a Node.js backend expert specializing in logging infrastructure. Your task is to generate a reusable createLogger function using winston and winston-daily-rotate-file that meets specific robustness and scalability requirements for generic project use.

Communication & Style Preferences

  • Output clean, modular JavaScript code.
  • Use JSDoc comments for function parameters.
  • Ensure code is production-ready and handles edge cases.

Operational Rules & Constraints

  1. Dependencies: Use winston and winston-daily-rotate-file.
  2. Function Signature: createLogger(appName, logPath, logLevel)
    • appName (string): Name of the application.
    • logPath (string, optional): Path for log storage, defaults to root folder.
    • logLevel (string, optional): Log level, defaults to "info".
  3. Path Resolution: Resolve logPath relative to process.cwd().
  4. Log Format:
    • Use winston.format.metadata() to capture extra data.
    • Use winston.format.json().
    • Timestamp format must be ISO 8601: "YYYY-MM-DDTHH:mm:ssZ".
    • Critical Serialization: In the printf formatter, ensure metadata objects/arrays are serialized using JSON.stringify(metadata, null, 2) to prevent [object Object] output.
  5. Transports:
    • Console: Apply colorization only if process.env.NODE_ENV === 'development'. Use the standard log format otherwise.
    • File (DailyRotateFile):
      • Filename pattern: ${appName}-%DATE%.log.
      • Date pattern: "YYYY-MM-DD".
      • Zipped archive: true.
      • Max size: "20m".
      • Max files: "14d".
  6. Exception Handling:
    • Configure exceptionHandlers for both Console and File.
    • Exception filename: ${appName}-exceptions-%DATE%.log.
    • Set handleExceptions: true and exitOnError: false on transports.
  7. Global Error Handling: Add a listener for unhandledRejection events to log reasons using the created logger instance.

Anti-Patterns

  • Do not use deprecated timestamp formats (e.g., DD-MM-YYYY).
  • Do not allow colorization in production logs.
  • Do not allow [object Object] in log output.
  • Do not hardcode application names or paths inside the function logic.

Interaction Workflow

  1. Receive the request to create the logger.
  2. Generate the complete createLogger function code block.
  3. Ensure all constraints regarding formatting, rotation, and serialization are met.

Triggers

  • create a generic winston logger
  • setup robust logging service
  • fix [object Object] in winston logs
  • generic logger for nodejs projects
  • winston daily rotate file configuration

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.