Skip to content

Commit b8a5f2e

Browse files
committed
changed readme
1 parent b363a99 commit b8a5f2e

1 file changed

Lines changed: 82 additions & 8 deletions

File tree

README.md

Lines changed: 82 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
# 🧠 @codecorn/corn-logger
1+
# 🌽 @codecorn/corn-logger
22

3-
> Logger stiloso, potente e ANSI-friendly per Node.js e TypeScript.
3+
> 🧠 Logger TypeScript avanzato per Node.js con supporto a colori, salvataggio su file, sub-contesto e livello log.
44
> Colori, contesto, stack trace, log file, livelli e supporto a `.env`.
5+
> Basato su [`console-log-colors`](https://www.npmjs.com/package/console-log-colors) e ottimizzato per ambienti CLI/DevOps.
56
6-
[![npm version](https://img.shields.io/npm/v/@codecorn/corn-logger.svg?style=flat-square)](https://www.npmjs.com/package/@codecorn/corn-logger)
7-
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat-square)](LICENSE)
8-
[![CodeCorn™](https://img.shields.io/badge/powered%20by-CodeCorn™-ff69b4?style=flat-square)](https://codecorn.it)
7+
[![Downloads](https://img.shields.io/npm/dt/@codecorn/corn-logger?color=blue&label=npm%20downloads)](https://www.npmjs.com/package/@codecorn/corn-logger)
8+
[![npm version](https://img.shields.io/npm/v/@codecorn/corn-logger?color=brightgreen&logo=npm)](https://www.npmjs.com/package/@codecorn/corn-logger)
9+
[![GitHub stars](https://img.shields.io/github/stars/CodeCornTech/corn-logger?style=social)](https://github.com/CodeCornTech/corn-logger)
10+
[![GitHub issues](https://img.shields.io/github/issues/CodeCornTech/corn-logger?color=blue)](https://github.com/CodeCornTech/corn-logger/issues)
911
[![Tests](https://github.com/CodeCornTech/corn-logger/actions/workflows/test.yml/badge.svg)](https://github.com/CodeCornTech/corn-logger/actions/workflows/test.yml)
12+
[![MIT License](https://img.shields.io/github/license/CodeCornTech/corn-logger)](LICENSE)
1013

1114
---
1215

@@ -16,6 +19,12 @@
1619
npm install @codecorn/corn-logger
1720
```
1821

22+
oppure con yarn:
23+
24+
```bash
25+
yarn add @codecorn/corn-logger
26+
```
27+
1928
> ⚠️ Il logger legge automaticamente variabili da `.env` se presenti (`dotenv.config()` è incluso).
2029
2130
---
@@ -38,9 +47,13 @@ npm install @codecorn/corn-logger
3847
import * as dotenv from 'dotenv';
3948
dotenv.config();
4049

41-
import { logInfo, logError, logWarn, logDebug } from '@codecorn/corn-logger';
50+
import { logInfo, logError, logWarn, logDebug, logMessage } from '@codecorn/corn-logger';
4251

43-
logInfo('BOOT', 'Logger pronto 🚀');
52+
logMessage('DEBUG', 'BOOT', 'Logger pronto 🚀');
53+
logInfo('MAIN', 'Tutto ok');
54+
logWarn('INIT', { warning: 'config mancante' });
55+
logError('DB', new Error('Connessione fallita'), 'DBConnect');
56+
logDebug('SERVICE', { id: 123, state: 'running' }, 'JobRunner');
4457
```
4558

4659
---
@@ -61,14 +74,48 @@ logDebug('AUTH', { user: 'admin', role: 'superuser' }, 'SessionPayload');
6174
6275
---
6376

64-
## ⚙️ Variabili `.env`
77+
## ⚙️ Variabili `.env` e 📦 Logger su File
78+
79+
Per abilitare la scrittura su file nella directory `logs/`:
6580

6681
```env
6782
LOG_STORE=true
6883
```
6984

7085
> Se `LOG_STORE=true`, ogni log sarà anche salvato in file `logs/YYYY-MM-DD.log`.
7186
87+
Output nel formato:
88+
89+
```
90+
[2025-08-05 14:33:05] [SERVICE] DEBUG > JobRunner:
91+
{ id: 123, state: 'running' }
92+
```
93+
94+
---
95+
96+
## ✨ Features
97+
98+
- ✅ Colorazione ANSI per ogni livello log
99+
- ✅ Sub-context support (`logError(context, err, subContext)`)
100+
- ✅ Supporto a `Error`, `object`, `string`, `null`, `undefined`
101+
- ✅ Salvataggio su file con timestamp (`LOG_STORE=true`)
102+
- ✅ Estendibile e minimalista
103+
104+
---
105+
106+
## 🔧 Scripts utili
107+
108+
Nel tuo `package.json`:
109+
110+
```json
111+
"scripts": {
112+
"build": "tsc",
113+
"dev": "tsc --watch",
114+
"lint": "tsc --noEmit",
115+
"prepare": "npm run build"
116+
}
117+
```
118+
72119
---
73120

74121
## 🗂 Struttura progetto
@@ -89,6 +136,25 @@ corn-logger/
89136

90137
---
91138

139+
## 🛠 Integrazione CLI (facoltativa)
140+
141+
Puoi usare il logger anche da terminale:
142+
143+
```bash
144+
npx cornlog --context "SYSTEM" --level info --message "Avvio completato"
145+
```
146+
147+
---
148+
149+
## 🧪 Test
150+
151+
```bash
152+
npm run lint
153+
npm test
154+
```
155+
156+
---
157+
92158
## 👤 Maintainer
93159

94160
<div style="display: flex; justify-content: space-between; align-items: center;">
@@ -116,4 +182,12 @@ corn-logger/
116182

117183
MIT © [CodeCorn™](https://codecorn.it)
118184

185+
Distribuito sotto licenza [MIT](LICENSE).
186+
119187
---
188+
189+
### 🤝 Contribuisci
190+
191+
Pull request benvenute. Per grosse modifiche apri una issue prima di iniziare.
192+
193+
> Powered by CodeCorn™ 🚀

0 commit comments

Comments
 (0)