@helzady/zady 1.0.0 → 1.1.0
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.
- package/README.md +76 -39
- package/package.json +5 -2
- package/build/config/defaults.d.ts +0 -6
- package/build/config/defaults.js +0 -6
- package/build/config/index.d.ts +0 -1
- package/build/config/index.js +0 -1
- package/build/core/colors.d.ts +0 -21
- package/build/core/colors.js +0 -22
- package/build/core/formatter.d.ts +0 -1
- package/build/core/formatter.js +0 -9
- package/build/core/index.d.ts +0 -4
- package/build/core/index.js +0 -4
- package/build/core/terminalStyle.d.ts +0 -8
- package/build/core/terminalStyle.js +0 -8
- package/build/core/types.d.ts +0 -7
- package/build/core/types.js +0 -2
- package/build/functions/error.d.ts +0 -2
- package/build/functions/error.js +0 -19
- package/build/functions/index.d.ts +0 -4
- package/build/functions/index.js +0 -4
- package/build/functions/log.d.ts +0 -1
- package/build/functions/log.js +0 -5
- package/build/functions/success.d.ts +0 -1
- package/build/functions/success.js +0 -5
- package/build/functions/warn.d.ts +0 -1
- package/build/functions/warn.js +0 -5
- package/build/index.d.ts +0 -38
- package/build/index.js +0 -11
- package/build/utils/formatDate.d.ts +0 -1
- package/build/utils/formatDate.js +0 -10
- package/build/utils/index.d.ts +0 -2
- package/build/utils/index.js +0 -2
- package/build/utils/precess.d.ts +0 -1
- package/build/utils/precess.js +0 -4
package/README.md
CHANGED
|
@@ -1,78 +1,115 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Zady
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Logger leve para Node.js com saída colorida no terminal.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
7
|
## 📦 Instalação
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
|
-
npm install zady
|
|
10
|
+
npm install @helzady/zady
|
|
11
11
|
```
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
|
-
## 🚀 Uso
|
|
15
|
+
## 🚀 Uso
|
|
16
16
|
|
|
17
17
|
```ts
|
|
18
|
-
|
|
19
|
-
import { log, warn, error, success, crash } from "@helzady/logger"
|
|
18
|
+
import zady from "@helzady/zady"
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
zady.log("Mensagem de debug")
|
|
21
|
+
zady.info("Servidor iniciado na porta 3000")
|
|
22
|
+
zady.warn("Variável de ambiente não definida")
|
|
23
|
+
zady.success("Conexão estabelecida")
|
|
24
|
+
zady.error("Falha crítica", { error: new Error("stack trace aqui") })
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Ou com destructuring:
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
warn
|
|
29
|
+
```ts
|
|
30
|
+
import { log, info, warn, success, error } from "@helzady/zady"
|
|
31
|
+
```
|
|
26
32
|
|
|
27
|
-
|
|
28
|
-
error("Algo deu errado")
|
|
33
|
+
---
|
|
29
34
|
|
|
30
|
-
|
|
31
|
-
success("Operação concluída")
|
|
35
|
+
## 🧾 Saída
|
|
32
36
|
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
```bash
|
|
38
|
+
[18/05/2026 14:00] [LOG] Mensagem de debug # cinza
|
|
39
|
+
[18/05/2026 14:00] [INFO] Servidor na porta 3000 # azul
|
|
40
|
+
[18/05/2026 14:00] [WARN] Variável não definida # amarelo
|
|
41
|
+
[18/05/2026 14:00] [SUCCESS] Conexão estabelecida # verde
|
|
42
|
+
[18/05/2026 14:00] [ERROR] Falha crítica # vermelho
|
|
35
43
|
```
|
|
36
44
|
|
|
37
45
|
---
|
|
38
46
|
|
|
39
|
-
##
|
|
47
|
+
## 📌 Funções disponíveis
|
|
48
|
+
|
|
49
|
+
| Função | Prefix | Cor | Descrição |
|
|
50
|
+
|---|---|---|---|
|
|
51
|
+
| `log(message)` | `LOG` | Cinza | Debug e mensagens de desenvolvimento |
|
|
52
|
+
| `info(message)` | `INFO` | Azul | Informações relevantes do sistema |
|
|
53
|
+
| `warn(message)` | `WARN` | Amarelo | Avisos que não encerram o processo |
|
|
54
|
+
| `success(message)` | `SUCCESS` | Verde | Confirmação de operações bem-sucedidas |
|
|
55
|
+
| `error(message, options?)` | `ERROR` | Vermelho | Erro crítico — **encerra o processo** |
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## ⚙️ Opções da função `error`
|
|
60
|
+
|
|
61
|
+
A função `error` aceita um segundo argumento com as seguintes opções:
|
|
40
62
|
|
|
41
63
|
```ts
|
|
42
|
-
|
|
43
|
-
code
|
|
44
|
-
prefix
|
|
45
|
-
showStack
|
|
46
|
-
timestamp
|
|
47
|
-
error
|
|
64
|
+
error("Mensagem de erro", {
|
|
65
|
+
code?: number // código de saída do processo (padrão: 1)
|
|
66
|
+
prefix?: string // prefixo customizado (padrão: "ERROR")
|
|
67
|
+
showStack?: boolean // exibir stack trace (padrão: true)
|
|
68
|
+
timestamp?: boolean // exibir data/hora (padrão: true)
|
|
69
|
+
error?: unknown // objeto de erro para exibir o stack
|
|
48
70
|
})
|
|
49
71
|
```
|
|
50
72
|
|
|
73
|
+
Exemplo:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
try {
|
|
77
|
+
// ...
|
|
78
|
+
} catch (err) {
|
|
79
|
+
error("Falha ao conectar ao banco", {
|
|
80
|
+
code: 1,
|
|
81
|
+
error: err,
|
|
82
|
+
showStack: true,
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
51
87
|
---
|
|
52
88
|
|
|
53
|
-
## 🎨
|
|
89
|
+
## 🎨 Estilos
|
|
54
90
|
|
|
55
|
-
|
|
56
|
-
* Prefixos personalizados
|
|
57
|
-
* Timestamp formatado (DD/MM/YYYY HH:mm)
|
|
58
|
-
* Stack trace opcional
|
|
59
|
-
* Encerramento seguro do processo
|
|
91
|
+
A lib também expõe utilitários de estilo ANSI para uso direto no terminal:
|
|
60
92
|
|
|
61
|
-
|
|
93
|
+
```ts
|
|
94
|
+
import zady from "@helzady/zady"
|
|
62
95
|
|
|
63
|
-
|
|
96
|
+
const { colors, bgColors, terminalStyle } = zady.style
|
|
64
97
|
|
|
98
|
+
console.log(`${colors.cyan}Texto ciano${terminalStyle.reset}`)
|
|
99
|
+
console.log(`${bgColors.red}Fundo vermelho${terminalStyle.reset}`)
|
|
65
100
|
```
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
101
|
+
|
|
102
|
+
### `colors`
|
|
103
|
+
`black` · `red` · `green` · `yellow` · `blue` · `magenta` · `cyan` · `white` · `gray`
|
|
104
|
+
|
|
105
|
+
### `bgColors`
|
|
106
|
+
`black` · `red` · `green` · `yellow` · `blue` · `magenta` · `cyan` · `white`
|
|
107
|
+
|
|
108
|
+
### `terminalStyle`
|
|
109
|
+
`reset` · `negrito` · `fraco` · `italico` · `sublinhado` · `riscado`
|
|
73
110
|
|
|
74
111
|
---
|
|
75
112
|
|
|
76
113
|
## 📄 Licença
|
|
77
114
|
|
|
78
|
-
MIT
|
|
115
|
+
MIT — [HelzadyDev](https://github.com/HelzadyDev)
|
package/package.json
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helzady/zady",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public"
|
|
6
|
+
},
|
|
4
7
|
"description": "um logger simples e poderoso para Node.js, com saídas formatadas no console, tratamento de erros e utilitários focados no desenvolvedor.",
|
|
5
8
|
"homepage": "https://github.com/HelzadyDev/zady#readme",
|
|
6
9
|
"bugs": {
|
|
@@ -11,7 +14,7 @@
|
|
|
11
14
|
"url": "git+https://github.com/HelzadyDev/zady.git"
|
|
12
15
|
},
|
|
13
16
|
"license": "MIT",
|
|
14
|
-
"author": "
|
|
17
|
+
"author": "HelzadyDev",
|
|
15
18
|
"type": "module",
|
|
16
19
|
"files": [
|
|
17
20
|
"build"
|
package/build/config/defaults.js
DELETED
package/build/config/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./defaults.js";
|
package/build/config/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./defaults.js";
|
package/build/core/colors.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare const colors: {
|
|
2
|
-
black: string;
|
|
3
|
-
red: string;
|
|
4
|
-
green: string;
|
|
5
|
-
yellow: string;
|
|
6
|
-
blue: string;
|
|
7
|
-
magenta: string;
|
|
8
|
-
cyan: string;
|
|
9
|
-
white: string;
|
|
10
|
-
gray: string;
|
|
11
|
-
};
|
|
12
|
-
export declare const bgColors: {
|
|
13
|
-
black: string;
|
|
14
|
-
red: string;
|
|
15
|
-
green: string;
|
|
16
|
-
yellow: string;
|
|
17
|
-
blue: string;
|
|
18
|
-
magenta: string;
|
|
19
|
-
cyan: string;
|
|
20
|
-
white: string;
|
|
21
|
-
};
|
package/build/core/colors.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
// Define cores ANSI para terminal
|
|
2
|
-
export const colors = {
|
|
3
|
-
"black": "\x1b[30",
|
|
4
|
-
"red": "\x1b[31m",
|
|
5
|
-
"green": "\x1b[32m",
|
|
6
|
-
"yellow": "\x1b[33m",
|
|
7
|
-
"blue": "\x1b[34m",
|
|
8
|
-
"magenta": "\x1b[35",
|
|
9
|
-
"cyan": "\x1b[36",
|
|
10
|
-
"white": "\x1b[37m",
|
|
11
|
-
"gray": "\x1b[90m",
|
|
12
|
-
};
|
|
13
|
-
export const bgColors = {
|
|
14
|
-
"black": "\x1b[40m",
|
|
15
|
-
"red": "\x1b[41m",
|
|
16
|
-
"green": "\x1b[42m",
|
|
17
|
-
"yellow": "\x1b[43m",
|
|
18
|
-
"blue": "\x1b[44m",
|
|
19
|
-
"magenta": "\x1b[45m",
|
|
20
|
-
"cyan": "\x1b[46m",
|
|
21
|
-
"white": "\x1b[47m",
|
|
22
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function formatMenssage(message: string, prefix: string, color: string, useTimestamp: boolean): string;
|
package/build/core/formatter.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { colors, terminalStyle } from "#core";
|
|
2
|
-
import { getTimestamp } from "#utils";
|
|
3
|
-
// Função responsavel por montar a mensagem fatal
|
|
4
|
-
export function formatMenssage(message, prefix, color, useTimestamp) {
|
|
5
|
-
const time = useTimestamp
|
|
6
|
-
? `${colors.gray}[${getTimestamp()}]${terminalStyle.reset}`
|
|
7
|
-
: "";
|
|
8
|
-
return `${time}${color}[${prefix}]${terminalStyle.reset} ${message}`;
|
|
9
|
-
}
|
package/build/core/index.d.ts
DELETED
package/build/core/index.js
DELETED
package/build/core/types.d.ts
DELETED
package/build/core/types.js
DELETED
package/build/functions/error.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// import { colors, formatMenssage } from "#core";
|
|
2
|
-
// // log de erro
|
|
3
|
-
// export function error(message: string): void {
|
|
4
|
-
// console.error(formatMenssage(message, "ERROR", colors.red, true))
|
|
5
|
-
// }
|
|
6
|
-
import { colors, formatMenssage } from "#core";
|
|
7
|
-
import { defaults } from "#config";
|
|
8
|
-
// função fatal que encerra o processo
|
|
9
|
-
export function error(message, options = {}) {
|
|
10
|
-
const { code = defaults.code, prefix = "FATAL", showStack = defaults.showStack, timestamp = defaults.timeStamp, error, } = options;
|
|
11
|
-
// Exibe mensagen formatada
|
|
12
|
-
console.error(formatMenssage(message, prefix, colors.red, timestamp));
|
|
13
|
-
// Exibe stack trace se existir
|
|
14
|
-
if (showStack && error instanceof Error) {
|
|
15
|
-
console.error(error.stack);
|
|
16
|
-
}
|
|
17
|
-
// Encerra o processo
|
|
18
|
-
process.exit(code);
|
|
19
|
-
}
|
package/build/functions/index.js
DELETED
package/build/functions/log.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function log(message: string): void;
|
package/build/functions/log.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function success(message: string): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function warn(message: string): void;
|
package/build/functions/warn.js
DELETED
package/build/index.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
declare const logger: {
|
|
2
|
-
style: {
|
|
3
|
-
bgColors: {
|
|
4
|
-
black: string;
|
|
5
|
-
red: string;
|
|
6
|
-
green: string;
|
|
7
|
-
yellow: string;
|
|
8
|
-
blue: string;
|
|
9
|
-
magenta: string;
|
|
10
|
-
cyan: string;
|
|
11
|
-
white: string;
|
|
12
|
-
};
|
|
13
|
-
colors: {
|
|
14
|
-
black: string;
|
|
15
|
-
red: string;
|
|
16
|
-
green: string;
|
|
17
|
-
yellow: string;
|
|
18
|
-
blue: string;
|
|
19
|
-
magenta: string;
|
|
20
|
-
cyan: string;
|
|
21
|
-
white: string;
|
|
22
|
-
gray: string;
|
|
23
|
-
};
|
|
24
|
-
terminalStyle: {
|
|
25
|
-
reset: string;
|
|
26
|
-
negrito: string;
|
|
27
|
-
fraco: string;
|
|
28
|
-
italico: string;
|
|
29
|
-
sublinhado: string;
|
|
30
|
-
riscado: string;
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
error(message: string, options?: import("#core").ErrorOptions): never;
|
|
34
|
-
log(message: string): void;
|
|
35
|
-
success(message: string): void;
|
|
36
|
-
warn(message: string): void;
|
|
37
|
-
};
|
|
38
|
-
export default logger;
|
package/build/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function getTimestamp(): string;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Retorna data no formato DD/MM/YYYY HH:mm
|
|
2
|
-
export function getTimestamp() {
|
|
3
|
-
const now = new Date();
|
|
4
|
-
const day = String(now.getDate()).padStart(2, "0");
|
|
5
|
-
const month = String(now.getMonth() + 1).padStart(2, "0");
|
|
6
|
-
const year = now.getFullYear();
|
|
7
|
-
const hours = String(now.getHours()).padStart(2, "0");
|
|
8
|
-
const minutes = String(now.getMinutes()).padStart(2, "0");
|
|
9
|
-
return `${day}/${month}/${year} ${hours}:${minutes}`;
|
|
10
|
-
}
|
package/build/utils/index.d.ts
DELETED
package/build/utils/index.js
DELETED
package/build/utils/precess.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function exitProcess(code: string): never;
|
package/build/utils/precess.js
DELETED