@jmlq/logger-plugin-fs 0.1.0-alpha.4 → 0.1.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +29 -8
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -53,9 +53,9 @@ Este plugin **depende** de [`@jmlq/logger`](https://www.npmjs.com/package/@jmlq/
53
53
  > > > - `create-fs-datasource.ts` — Ensambla VO + adaptadores + casos de uso y devuelve un `ILogDatasource`.
54
54
  > > - `index.ts` — Barrel: reexporta la factory y VO/contratos públicos (`RotationPolicy`, `FileNamePattern`).
55
55
 
56
- ---
56
+ #### [VER MAS](./ARQUITECTURA.md)
57
57
 
58
- ### 🧩 Configuración
58
+ ## 🧩 Configuración
59
59
 
60
60
  ### 🔐 Variables de Entorno (.env)
61
61
 
@@ -81,11 +81,7 @@ LOGGER_LEVEL=info # trace|debug|info|warn|error|fatal
81
81
 
82
82
  ```tsx
83
83
  import { createLogger, LogLevel } from "@jmlq/logger";
84
- import {
85
- createFsDatasource,
86
- RotationPolicy,
87
- FileNamePattern,
88
- } from "@jmlq/logger-plugin-fs";
84
+ import { createFsDatasource } from "@jmlq/logger-plugin-fs";
89
85
 
90
86
  const ds = createFsDatasource({
91
87
  basePath: "./logs", // Carpeta destino
@@ -112,7 +108,32 @@ process.on("SIGTERM", async () => {
112
108
  });
113
109
  ```
114
110
 
115
- #### Opciones soportadas
111
+ También:
112
+
113
+ ```ts
114
+ import { createLogger, LogLevel } from "@jmlq/logger";
115
+ import {
116
+ createFsDatasource,
117
+ RotationPolicy,
118
+ FileNamePattern,
119
+ } from "@jmlq/logger-plugin-fs";
120
+
121
+ // Validación/invariantes tempranas con VO (throws si es inválido)
122
+ const pt = new FileNamePattern("app-{yyyy}{MM}{dd}.log");
123
+ const rt = new RotationPolicy("size", 50 /* maxSizeMB */);
124
+
125
+ const ds = createFsDatasource({
126
+ basePath: "./logs",
127
+ mkdir: true,
128
+ // La factory acepta primitives; usamos los VO arriba solo para validar/centrar la decisión
129
+ fileNamePattern: pt.pattern,
130
+ rotation: { by: rt.by, maxSizeMB: rotation.maxSizeMB },
131
+ });
132
+
133
+ const logger = createLogger(ds, { minLevel: LogLevel.INFO });
134
+ ```
135
+
136
+ #### ⚙️ Opciones soportadas
116
137
 
117
138
  > - `basePath: string` – carpeta donde se guardan los logs.
118
139
  > - `mkdir?: boolean` – crea la carpeta si no existe.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jmlq/logger-plugin-fs",
3
- "version": "0.1.0-alpha.4",
3
+ "version": "0.1.0-alpha.5",
4
4
  "author": "MLahuasi",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -24,7 +24,7 @@
24
24
  "jest": "^30.1.3"
25
25
  },
26
26
  "dependencies": {
27
- "@jmlq/logger": "^0.1.0-alpha.2"
27
+ "@jmlq/logger": "^0.1.0-alpha.5"
28
28
  },
29
29
  "overrides": {
30
30
  "test-exclude": "^7.0.1",