{"record":{"id":"733da547be39108d","repo":"winstonjs/winston","slug":"s-was-removed-in-winston-3-0-0-use-a-custom","errorCode":null,"errorMessage":"{ %s } was removed in winston@3.0.0.\nUse a custom winston.format = winston.format(function) instead.","messagePattern":"(.+?) was removed in winston@3\\.0\\.0\\.\nUse a custom winston\\.format = winston\\.format\\(function\\) instead\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/winston/common.js","lineNumber":26,"sourceCode":"'use strict';\n\nconst { format } = require('util');\n\n/**\n * Set of simple deprecation notices and a way to expose them for a set of\n * properties.\n * @type {Object}\n * @private\n */\nexports.warn = {\n  deprecated(prop) {\n    return () => {\n      throw new Error(format('{ %s } was removed in winston@3.0.0.', prop));\n    };\n  },\n  useFormat(prop) {\n    return () => {\n      throw new Error([\n        format('{ %s } was removed in winston@3.0.0.', prop),\n        'Use a custom winston.format = winston.format(function) instead.'\n      ].join('\\n'));\n    };\n  },\n  forFunctions(obj, type, props) {\n    props.forEach(prop => {\n      obj[prop] = exports.warn[type](prop);\n    });\n  },\n  forProperties(obj, type, props) {\n    props.forEach(prop => {\n      const notice = exports.warn[type](prop);\n      Object.defineProperty(obj, prop, {\n        get: notice,\n        set: notice\n      });\n    });","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/winstonjs/winston/blob/ff0b79de8562bb322c390fbc82fe71c11f373428/lib/winston/common.js#L8-L44","documentation":"This variant of the deprecation helper (`useFormat` in lib/winston/common.js) targets winston 2.x APIs that were replaced by the winston 3 format system. The error appends the migration hint: instead of the removed API, pass a custom function to `winston.format` (i.e. `winston.format(fn)`), which returns a Format transform usable in `format` option arrays.","triggerScenarios":"Calling a removed winston 2.x formatting-related function registered via `warn.useFormat(prop)` — e.g. legacy formatter helpers or logger-level format options that were folded into the `winston.format` pipeline in 3.0.0.","commonSituations":"Migrating winston 2.x code that used `formatter:` options or `winston.formatters.*` helpers; old docs/tutorials showing v2 custom formatting; plugins built against the v2 formatter signature.","solutions":["Rewrite the removed formatter as a winston 3 custom format: `const myFormat = winston.format((info) => { /* mutate info */ return info; })()` and add it to the logger's `format` array.","Use built-in winston 3 formats (`format.printf`, `format.combine`, `format.json`, `format.cli`) to replace the v2 helper.","Consult UPGRADE-3.0.md for the specific `{ prop }` named in the message.","Temporarily pin winston ^2.4.x if migration is not feasible now."],"exampleFix":"// before (winston 2.x)\nconst logger = new winston.Logger({\n  formatter: (options) => options.level + ': ' + options.message\n});\n\n// after (winston 3.x)\nconst logger = winston.createLogger({\n  format: winston.format.combine(\n    winston.format((info) => { info.output = info.level + ': ' + info.message; return info; })(),\n    winston.format.printf((info) => info.output)\n  ),\n  transports: [new winston.transports.Console()]\n});","handlingStrategy":"validation","validationCode":"if (typeof legacyFormatter === 'function' && !/^\\s*\\(?(info|\\{)/.test(legacyFormatter.toString())) {\n  console.warn('v2 formatter signature detected; rewrite as winston.format(fn)');\n}","typeGuard":"function isFormatTransform(f) { return f && typeof f === 'object' && typeof f.transform === 'function'; }","tryCatchPattern":"try {\n  createLoggerWithLegacyFormat();\n} catch (err) {\n  if (err.message.includes('winston.format(function)')) {\n    logger = winston.createLogger({ format: winston.format(legacyFn)(), transports });\n  } else { throw err; }\n}","preventionTips":["Convert `formatter:` options to `winston.format(fn)` during migration, not after","Write logger config in code review-checked modules rather than ad-hoc snippets","Add a smoke test that constructs the logger at CI time","Check UPGRADE-3.0.md for formatter mappings"],"tags":["winston","deprecation","format","breaking-change"],"backgroundTag":"removed-in-major-version","analyzedSha":"ff0b79de8562bb322c390fbc82fe71c11f373428","analyzedAt":"2026-08-31T13:33:44.585Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}