{
  "slug": "logger",
  "runtimes": {
    "node": {
      "frameworks": {
        "express": {
          "prompt": "Select a logging library: ",
          "variants": {
            "pino": {
              "label": "Pino (High-performancer)",
              "env": [
                "LOG_LEVEL",
                "NODE_ENV"
              ],
              "dependencies": {
                "runtime": [
                  "pino",
                  "pino-pretty",
                  "dotenv-flow",
                  "cross-env",
                  "zod"
                ],
                "dev": []
              },
              "architectures": {
                "feature": {
                  "files": [
                    {
                      "type": "file",
                      "path": "src/shared/utils/pino-logger.ts",
                      "content": "import pino from \"pino\";\nimport env from \"../configs/env\";\n\nconst isProduction = env.NODE_ENV === \"production\";\n\nexport const logger = pino({\n  level: env.LOG_LEVEL || \"info\",\n\n  base: {\n    pid: process.pid\n  },\n\n  timestamp: pino.stdTimeFunctions.isoTime,\n\n  formatters: {\n    level(label) {\n      return { level: label };\n    }\n  },\n\n  redact: {\n    paths: [\n      \"req.headers.authorization\",\n      \"req.headers.cookie\",\n      \"password\",\n      \"token\",\n      \"refreshToken\"\n    ],\n    censor: \"[REDACTED]\"\n  },\n\n  ...(isProduction\n    ? {}\n    : {\n        transport: {\n          target: \"pino-pretty\",\n          options: {\n            colorize: true,\n            translateTime: \"SYS:standard\",\n            ignore: \"pid,hostname\"\n          }\n        }\n      })\n});\n\n/**\n * USAGE:\n * \n  logger.warn({ userId: \"123\" }, \"Suspicious activity detected\");\n  logger.error(\n  { err: \"Database connection failed\" },\n  \"Database connection failed\"\n  );\n */"
                    },
                    {
                      "type": "file",
                      "path": "src/shared/configs/env.ts",
                      "content": "import \"dotenv-flow/config\";\nimport { z } from \"zod\";\n\nexport const envSchema = z.object({\n  NODE_ENV: z\n    .enum([\"development\", \"test\", \"production\"])\n    .default(\"development\"),\n\n  PORT: z.string().regex(/^\\d+$/, \"PORT must be a number\").transform(Number),\n\n  LOG_LEVEL: z\n    .enum([\"fatal\", \"error\", \"warn\", \"info\", \"debug\", \"trace\"])\n    .default(\"info\")\n});\n\nexport type Env = z.infer<typeof envSchema>;\n\nconst result = envSchema.safeParse(process.env);\n\nif (!result.success) {\n  console.error(\"❌ Invalid environment configuration\");\n  console.error(z.prettifyError(result.error));\n  process.exit(1);\n}\n\nexport const env: Readonly<Env> = Object.freeze(result.data);\n\nexport default env;\n"
                    }
                  ]
                },
                "mvc": {
                  "files": [
                    {
                      "type": "file",
                      "path": "src/utils/pino-logger.ts",
                      "content": "import pino from \"pino\";\nimport env from \"../configs/env\";\n\nconst isProduction = env.NODE_ENV === \"production\";\n\nexport const logger = pino({\n  level: env.LOG_LEVEL || \"info\",\n\n  base: {\n    pid: process.pid\n  },\n\n  timestamp: pino.stdTimeFunctions.isoTime,\n\n  formatters: {\n    level(label) {\n      return { level: label };\n    }\n  },\n\n  redact: {\n    paths: [\n      \"req.headers.authorization\",\n      \"req.headers.cookie\",\n      \"password\",\n      \"token\",\n      \"refreshToken\"\n    ],\n    censor: \"[REDACTED]\"\n  },\n\n  ...(isProduction\n    ? {}\n    : {\n        transport: {\n          target: \"pino-pretty\",\n          options: {\n            colorize: true,\n            translateTime: \"SYS:standard\",\n            ignore: \"pid,hostname\"\n          }\n        }\n      })\n});\n\n/**\n * USAGE:\n * \n  logger.warn({ userId: \"123\" }, \"Suspicious activity detected\");\n  logger.error(\n  { err: \"Database connection failed\" },\n  \"Database connection failed\"\n  );\n */\n"
                    },
                    {
                      "type": "file",
                      "path": "src/configs/env.ts",
                      "content": "import \"dotenv-flow/config\";\nimport { z } from \"zod\";\n\nexport const envSchema = z.object({\n  NODE_ENV: z\n    .enum([\"development\", \"test\", \"production\"])\n    .default(\"development\"),\n\n  PORT: z.string().regex(/^\\d+$/, \"PORT must be a number\").transform(Number),\n\n  LOG_LEVEL: z\n    .enum([\"fatal\", \"error\", \"warn\", \"info\", \"debug\", \"trace\"])\n    .default(\"info\")\n});\n\nexport type Env = z.infer<typeof envSchema>;\n\nconst result = envSchema.safeParse(process.env);\n\nif (!result.success) {\n  console.error(\"❌ Invalid environment configuration\");\n  console.error(z.prettifyError(result.error));\n  process.exit(1);\n}\n\nexport const env: Readonly<Env> = Object.freeze(result.data);\n\nexport default env;\n"
                    }
                  ]
                }
              }
            },
            "winston": {
              "label": "Winston (Flexible)",
              "env": [
                "LOG_LEVEL",
                "NODE_ENV"
              ],
              "dependencies": {
                "runtime": [
                  "winston",
                  "winston-daily-rotate-file",
                  "dotenv-flow",
                  "cross-env",
                  "zod"
                ],
                "dev": []
              },
              "architectures": {
                "feature": {
                  "files": [
                    {
                      "type": "file",
                      "path": "src/shared/utils/logger.ts",
                      "content": "import env from \"../configs/env\";\nimport winston from \"winston\";\nimport DailyRotateFile from \"winston-daily-rotate-file\";\n\nconst { combine, timestamp, printf, colorize, errors } = winston.format;\n\nconst logFormat = printf(({ level, message, timestamp, stack }) => {\n  return `${timestamp} [${level}] : ${stack || message}`;\n});\n\nconst transports: winston.transport[] = [];\n\n/**\n * Console logging (development / local)\n */\nif (env.NODE_ENV !== \"production\") {\n  transports.push(\n    new winston.transports.Console({\n      format: combine(\n        colorize(),\n        timestamp({ format: \"YYYY-MM-DD HH:mm:ss\" }),\n        errors({ stack: true }),\n        logFormat\n      )\n    })\n  );\n}\n\n/**\n * File logging (staging / production)\n */\nif (env.NODE_ENV !== \"development\") {\n  transports.push(\n    new DailyRotateFile({\n      dirname: \"logs/app\",\n      filename: \"app-%DATE%.log\",\n      datePattern: \"YYYY-MM-DD\",\n      zippedArchive: true,\n      maxSize: \"20m\",\n      maxFiles: \"14d\",\n      level: \"info\"\n    })\n  );\n\n  transports.push(\n    new DailyRotateFile({\n      dirname: \"logs/error\",\n      filename: \"errors-%DATE%.log\",\n      datePattern: \"YYYY-MM-DD\",\n      zippedArchive: true,\n      maxSize: \"20m\",\n      maxFiles: \"30d\",\n      level: \"error\"\n    })\n  );\n}\n\nexport const logger = winston.createLogger({\n  level: env.LOG_LEVEL,\n  format: combine(\n    timestamp({ format: \"YYYY-MM-DD HH:mm:ss\" }),\n    errors({ stack: true }),\n    logFormat\n  ),\n  transports,\n  exitOnError: false\n});\n\n/**\n * ? USAGE:\n  logger.info(\"Server started successfully\");\n  logger.warn(\"Disk space running low\");\n  logger.error(\"Failed to connect to database\", { error: \"Error Stack...\" });\n *\n*/\n"
                    },
                    {
                      "type": "file",
                      "path": "src/shared/configs/env.ts",
                      "content": "import \"dotenv-flow/config\";\nimport { z } from \"zod\";\n\nexport const envSchema = z.object({\n  NODE_ENV: z\n    .enum([\"development\", \"test\", \"production\"])\n    .default(\"development\"),\n\n  PORT: z.string().regex(/^\\d+$/, \"PORT must be a number\").transform(Number),\n\n  LOG_LEVEL: z\n    .enum([\"fatal\", \"error\", \"warn\", \"info\", \"debug\", \"trace\"])\n    .default(\"info\")\n});\n\nexport type Env = z.infer<typeof envSchema>;\n\nconst result = envSchema.safeParse(process.env);\n\nif (!result.success) {\n  console.error(\"❌ Invalid environment configuration\");\n  console.error(z.prettifyError(result.error));\n  process.exit(1);\n}\n\nexport const env: Readonly<Env> = Object.freeze(result.data);\n\nexport default env;"
                    }
                  ]
                },
                "mvc": {
                  "files": [
                    {
                      "type": "file",
                      "path": "src/utils/logger.ts",
                      "content": "import env from \"../configs/env\";\nimport winston from \"winston\";\nimport DailyRotateFile from \"winston-daily-rotate-file\";\n\nconst { combine, timestamp, printf, colorize, errors } = winston.format;\n\nconst logFormat = printf(({ level, message, timestamp, stack }) => {\n  return `${timestamp} [${level}] : ${stack || message}`;\n});\n\nconst transports: winston.transport[] = [];\n\n/**\n * Console logging (development / local)\n */\nif (env.NODE_ENV !== \"production\") {\n  transports.push(\n    new winston.transports.Console({\n      format: combine(\n        colorize(),\n        timestamp({ format: \"YYYY-MM-DD HH:mm:ss\" }),\n        errors({ stack: true }),\n        logFormat\n      )\n    })\n  );\n}\n\n/**\n * File logging (staging / production)\n */\nif (env.NODE_ENV !== \"development\") {\n  transports.push(\n    new DailyRotateFile({\n      dirname: \"logs/app\",\n      filename: \"app-%DATE%.log\",\n      datePattern: \"YYYY-MM-DD\",\n      zippedArchive: true,\n      maxSize: \"20m\",\n      maxFiles: \"14d\",\n      level: \"info\"\n    })\n  );\n\n  transports.push(\n    new DailyRotateFile({\n      dirname: \"logs/error\",\n      filename: \"errors-%DATE%.log\",\n      datePattern: \"YYYY-MM-DD\",\n      zippedArchive: true,\n      maxSize: \"20m\",\n      maxFiles: \"30d\",\n      level: \"error\"\n    })\n  );\n}\n\nexport const logger = winston.createLogger({\n  level: env.LOG_LEVEL,\n  format: combine(\n    timestamp({ format: \"YYYY-MM-DD HH:mm:ss\" }),\n    errors({ stack: true }),\n    logFormat\n  ),\n  transports,\n  exitOnError: false\n});\n\n/**\n * ? USAGE:\n  logger.info(\"Server started successfully\");\n  logger.warn(\"Disk space running low\");\n  logger.error(\"Failed to connect to database\", { error: \"Error Stack...\" });\n *\n*/"
                    },
                    {
                      "type": "file",
                      "path": "src/configs/env.ts",
                      "content": "import \"dotenv-flow/config\";\nimport { z } from \"zod\";\n\nexport const envSchema = z.object({\n  NODE_ENV: z\n    .enum([\"development\", \"test\", \"production\"])\n    .default(\"development\"),\n\n  PORT: z.string().regex(/^\\d+$/, \"PORT must be a number\").transform(Number),\n\n  LOG_LEVEL: z\n    .enum([\"fatal\", \"error\", \"warn\", \"info\", \"debug\", \"trace\"])\n    .default(\"info\")\n});\n\nexport type Env = z.infer<typeof envSchema>;\n\nconst result = envSchema.safeParse(process.env);\n\nif (!result.success) {\n  console.error(\"❌ Invalid environment configuration\");\n  console.error(z.prettifyError(result.error));\n  process.exit(1);\n}\n\nexport const env: Readonly<Env> = Object.freeze(result.data);\n\nexport default env;\n"
                    }
                  ]
                }
              }
            }
          }
        },
        "nextjs": {
          "prompt": "Select a logging library: ",
          "variants": {
            "pino": {
              "label": "Pino (High-performancer)",
              "env": [
                "LOG_LEVEL",
                "NODE_ENV"
              ],
              "dependencies": {
                "runtime": [
                  "pino",
                  "pino-pretty",
                  "zod"
                ],
                "dev": []
              },
              "architectures": {
                "file-api": {
                  "files": [
                    {
                      "type": "file",
                      "path": "src/utils/logger.ts",
                      "content": "import pino from \"pino\";\nimport env from \"@/configs/env\";\n\nconst isProduction = env.NODE_ENV === \"production\";\n\nexport const logger = pino({\n  level: env.LOG_LEVEL || \"info\",\n\n  base: {\n    pid: process.pid\n  },\n\n  timestamp: pino.stdTimeFunctions.isoTime,\n\n  formatters: {\n    level(label) {\n      return { level: label };\n    }\n  },\n\n  redact: {\n    paths: [\n      \"req.headers.authorization\",\n      \"req.headers.cookie\",\n      \"password\",\n      \"token\",\n      \"refreshToken\"\n    ],\n    censor: \"[REDACTED]\"\n  },\n\n  ...(isProduction\n    ? {}\n    : {\n        transport: {\n          target: \"pino-pretty\",\n          options: {\n            colorize: true,\n            translateTime: \"SYS:standard\",\n            ignore: \"pid,hostname\"\n          }\n        }\n      })\n});\n\n/**\n * USAGE:\n * \n  logger.warn({ userId: \"123\" }, \"Suspicious activity detected\");\n  logger.error(\n  { err: \"Database connection failed\" },\n  \"Database connection failed\"\n  );\n */\n"
                    },
                    {
                      "type": "file",
                      "path": "src/configs/env.ts",
                      "content": "import z from \"zod\";\n\nexport const envSchema = z.object({\n  NODE_ENV: z\n    .enum([\"development\", \"test\", \"production\"])\n    .default(\"development\"),\n\n  LOG_LEVEL: z\n    .enum([\"fatal\", \"error\", \"warn\", \"info\", \"debug\", \"trace\"])\n    .default(\"info\")\n});\n\nexport type Env = z.infer<typeof envSchema>;\n\nconst result = envSchema.safeParse(process.env);\n\nif (!result.success) {\n  console.error(\"❌ Invalid environment configuration\");\n  console.error(z.prettifyError(result.error));\n  process.exit(1);\n}\n\nexport const env: Readonly<Env> = Object.freeze(result.data);\n\nexport default env;\n"
                    }
                  ]
                }
              }
            },
            "winston": {
              "label": "Winston (Flexible)",
              "env": [
                "LOG_LEVEL",
                "NODE_ENV"
              ],
              "dependencies": {
                "runtime": [
                  "winston",
                  "winston-daily-rotate-file",
                  "zod"
                ],
                "dev": []
              },
              "architectures": {
                "file-api": {
                  "files": [
                    {
                      "type": "file",
                      "path": "src/utils/logger.ts",
                      "content": "import env from \"@/configs/env\";\nimport winston from \"winston\";\nimport DailyRotateFile from \"winston-daily-rotate-file\";\n\nconst { combine, timestamp, printf, colorize, errors } = winston.format;\n\nconst logFormat = printf(({ level, message, timestamp, stack }) => {\n  return `${timestamp} [${level}] : ${stack || message}`;\n});\n\nconst transports: winston.transport[] = [];\n\n/**\n * Console logging (development / local)\n */\nif (env.NODE_ENV !== \"production\") {\n  transports.push(\n    new winston.transports.Console({\n      format: combine(\n        colorize(),\n        timestamp({ format: \"YYYY-MM-DD HH:mm:ss\" }),\n        errors({ stack: true }),\n        logFormat\n      )\n    })\n  );\n}\n\n/**\n * File logging (staging / production)\n */\nif (env.NODE_ENV !== \"development\") {\n  transports.push(\n    new DailyRotateFile({\n      dirname: \"logs/app\",\n      filename: \"app-%DATE%.log\",\n      datePattern: \"YYYY-MM-DD\",\n      zippedArchive: true,\n      maxSize: \"20m\",\n      maxFiles: \"14d\",\n      level: \"info\"\n    })\n  );\n\n  transports.push(\n    new DailyRotateFile({\n      dirname: \"logs/error\",\n      filename: \"errors-%DATE%.log\",\n      datePattern: \"YYYY-MM-DD\",\n      zippedArchive: true,\n      maxSize: \"20m\",\n      maxFiles: \"30d\",\n      level: \"error\"\n    })\n  );\n}\n\nexport const logger = winston.createLogger({\n  level: env.LOG_LEVEL,\n  format: combine(\n    timestamp({ format: \"YYYY-MM-DD HH:mm:ss\" }),\n    errors({ stack: true }),\n    logFormat\n  ),\n  transports,\n  exitOnError: false\n});\n\n/**\n * ? USAGE:\n  logger.info(\"Server started successfully\");\n  logger.warn(\"Disk space running low\");\n  logger.error(\"Failed to connect to database\", { error: \"Error Stack...\" });\n *\n*/\n"
                    },
                    {
                      "type": "file",
                      "path": "src/configs/env.ts",
                      "content": "import z from \"zod\";\n\nexport const envSchema = z.object({\n  NODE_ENV: z\n    .enum([\"development\", \"test\", \"production\"])\n    .default(\"development\"),\n\n  LOG_LEVEL: z\n    .enum([\"fatal\", \"error\", \"warn\", \"info\", \"debug\", \"trace\"])\n    .default(\"info\")\n});\n\nexport type Env = z.infer<typeof envSchema>;\n\nconst result = envSchema.safeParse(process.env);\n\nif (!result.success) {\n  console.error(\"❌ Invalid environment configuration\");\n  console.error(z.prettifyError(result.error));\n  process.exit(1);\n}\n\nexport const env: Readonly<Env> = Object.freeze(result.data);\n\nexport default env;\n"
                    }
                  ]
                }
              }
            }
          }
        }
      }
    }
  }
}
