codigo0/backend/node_modules/logform/cli.js
planetazuzu 5d7a6500fe refactor: Fase 1 - Clean Architecture, refactorización modular y eliminación de duplicidades
-  Ticket 1.1: Estructura Clean Architecture en backend
-  Ticket 1.2: Schemas Zod compartidos
-  Ticket 1.3: Refactorización drugs.ts (1362 → 8 archivos modulares)
-  Ticket 1.4: Refactorización procedures.ts (3583 → 6 archivos modulares)
-  Ticket 1.5: Eliminación de duplicidades (~50 líneas)

Cambios principales:
- Creada estructura Clean Architecture en backend/src/
- Schemas Zod compartidos en backend/src/shared/schemas/
- Refactorización modular de drugs y procedures
- Utilidades genéricas en src/utils/ (filter, validation)
- Eliminados scripts obsoletos y documentación antigua
- Corregidos errores: QueryClient, import test-error-handling
- Build verificado y funcionando correctamente
2026-01-25 21:09:47 +01:00

53 lines
1.2 KiB
JavaScript

'use strict';
const { Colorizer } = require('./colorize');
const { Padder } = require('./pad-levels');
const { configs, MESSAGE } = require('triple-beam');
/**
* Cli format class that handles initial state for a a separate
* Colorizer and Padder instance.
*/
class CliFormat {
constructor(opts = {}) {
if (!opts.levels) {
opts.levels = configs.cli.levels;
}
this.colorizer = new Colorizer(opts);
this.padder = new Padder(opts);
this.options = opts;
}
/*
* function transform (info, opts)
* Attempts to both:
* 1. Pad the { level }
* 2. Colorize the { level, message }
* of the given `logform` info object depending on the `opts`.
*/
transform(info, opts) {
this.colorizer.transform(
this.padder.transform(info, opts),
opts
);
info[MESSAGE] = `${info.level}:${info.message}`;
return info;
}
}
/*
* function cli (opts)
* Returns a new instance of the CLI format that turns a log
* `info` object into the same format previously available
* in `winston.cli()` in `winston < 3.0.0`.
*/
module.exports = opts => new CliFormat(opts);
//
// Attach the CliFormat for registration purposes
//
module.exports.Format = CliFormat;