@logtape/pretty 1.0.0-dev.231

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/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Copyright 2024 Hong Minhee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,236 @@
1
+ # @logtape/pretty
2
+
3
+ Beautiful console formatter for [LogTape] - Perfect for local development!
4
+
5
+ [@logtape/pretty] provides a visually appealing formatter inspired by [Signale], designed to make your development logs easier to read and debug. With colorful icons, smart truncation, and perfect alignment, your logs have never looked better.
6
+
7
+ [LogTape]: https://github.com/dahlia/logtape
8
+ [@logtape/pretty]: https://github.com/dahlia/logtape/tree/main/pretty
9
+ [Signale]: https://github.com/klaudiosinani/signale
10
+
11
+ ## Features
12
+
13
+ - 🎨 **Beautiful Design**: Inspired by Signale with colorful icons and clean layout
14
+ - 🌈 **True Color Support**: Rich colors for modern terminals
15
+ - ✂️ **Smart Truncation**: Intelligent category truncation to maintain layout
16
+ - 📐 **Perfect Alignment**: Columns align beautifully for easy scanning
17
+ - 🎯 **Development Focused**: Optimized for local development experience
18
+ - 🚀 **Zero Dependencies**: Lightweight and fast
19
+
20
+ ## Installation
21
+
22
+ ### Deno
23
+ ```typescript
24
+ import { prettyFormatter } from "@logtape/pretty";
25
+ ```
26
+
27
+ ### Node.js
28
+ ```bash
29
+ npm install @logtape/pretty
30
+ ```
31
+
32
+ ### Bun
33
+ ```bash
34
+ bun add @logtape/pretty
35
+ ```
36
+
37
+ ## Quick Start
38
+
39
+ ```typescript
40
+ import { configure } from "@logtape/logtape";
41
+ import { getConsoleSink } from "@logtape/logtape/sink";
42
+ import { prettyFormatter } from "@logtape/pretty";
43
+
44
+ await configure({
45
+ sinks: {
46
+ console: getConsoleSink({
47
+ formatter: prettyFormatter
48
+ })
49
+ },
50
+ loggers: [
51
+ {
52
+ category: "my-app",
53
+ level: "debug",
54
+ sinks: ["console"]
55
+ }
56
+ ]
57
+ });
58
+
59
+ // Now your logs look beautiful!
60
+ const logger = getLogger("my-app");
61
+ logger.info`Server started on port ${3000}`;
62
+ logger.debug`Connected to database`;
63
+ logger.warn`Cache size exceeding 80% capacity`;
64
+ logger.error`Failed to process request: ${{ error: "timeout" }}`;
65
+ ```
66
+
67
+ ## Output Example
68
+
69
+ ```
70
+ ✨ info my-app.server Server started on port 3000
71
+ 🐛 debug my-app.database Connected to PostgreSQL
72
+ ⚠️ warn my-app.cache Cache size exceeding 80% capacity
73
+ ❌ error my-app...handler Failed to process request: { error: 'timeout' }
74
+ ```
75
+
76
+ ## Configuration
77
+
78
+ ### Basic Options
79
+
80
+ ```typescript
81
+ import { getPrettyFormatter } from "@logtape/pretty";
82
+
83
+ const formatter = getPrettyFormatter({
84
+ // Show timestamp
85
+ timestamp: "time", // "time" | "datetime" | false
86
+
87
+ // Customize icons
88
+ icons: {
89
+ info: "ℹ️ ",
90
+ error: "🔥"
91
+ },
92
+
93
+ // Control colors
94
+ colors: true,
95
+ dimMessage: true,
96
+ dimCategory: true,
97
+
98
+ // Category display
99
+ categoryWidth: 20,
100
+ categoryTruncate: "middle" // "middle" | "end" | false
101
+ });
102
+ ```
103
+
104
+ ### Timestamp Options
105
+
106
+ ```typescript
107
+ // No timestamp (default)
108
+ getPrettyFormatter({ timestamp: false })
109
+
110
+ // Time only (HH:MM:SS)
111
+ getPrettyFormatter({ timestamp: "time" })
112
+ // Output: 12:34:56 ✨ info app Message
113
+
114
+ // Date and time
115
+ getPrettyFormatter({ timestamp: "datetime" })
116
+ // Output: 2024-01-15 12:34:56 ✨ info app Message
117
+
118
+ // Custom formatter
119
+ getPrettyFormatter({
120
+ timestamp: (ts) => new Date(ts).toLocaleTimeString()
121
+ })
122
+ ```
123
+
124
+ ### Icon Customization
125
+
126
+ ```typescript
127
+ // Disable all icons
128
+ getPrettyFormatter({ icons: false })
129
+
130
+ // Custom icons for specific levels
131
+ getPrettyFormatter({
132
+ icons: {
133
+ info: "📘",
134
+ warning: "🔶",
135
+ error: "🚨",
136
+ fatal: "☠️ "
137
+ }
138
+ })
139
+
140
+ // Default icons:
141
+ // trace: 🔍
142
+ // debug: 🐛
143
+ // info: ✨
144
+ // warning: ⚠️
145
+ // error: ❌
146
+ // fatal: 💀
147
+ ```
148
+
149
+ ### Category Truncation
150
+
151
+ ```typescript
152
+ // Fixed width with middle truncation (default)
153
+ getPrettyFormatter({
154
+ categoryWidth: 20,
155
+ categoryTruncate: "middle"
156
+ })
157
+ // "app.server.http.middleware" → "app...middleware"
158
+
159
+ // End truncation
160
+ getPrettyFormatter({
161
+ categoryWidth: 20,
162
+ categoryTruncate: "end"
163
+ })
164
+ // "app.server.http.middleware" → "app.server.http..."
165
+
166
+ // No truncation
167
+ getPrettyFormatter({
168
+ categoryTruncate: false
169
+ })
170
+ ```
171
+
172
+ ### Color Control
173
+
174
+ ```typescript
175
+ // Disable colors (for CI/CD environments)
176
+ getPrettyFormatter({ colors: false })
177
+
178
+ // Control dimming
179
+ getPrettyFormatter({
180
+ dimMessage: false, // Full brightness messages
181
+ dimCategory: false // Full brightness categories
182
+ })
183
+ ```
184
+
185
+ ## Advanced Usage
186
+
187
+ ### Multiple Formatters
188
+
189
+ Use different formatters for different environments:
190
+
191
+ ```typescript
192
+ import { configure } from "@logtape/logtape";
193
+ import { getConsoleSink } from "@logtape/logtape/sink";
194
+ import { prettyFormatter } from "@logtape/pretty";
195
+ import { jsonLinesFormatter } from "@logtape/logtape";
196
+
197
+ const isDevelopment = process.env.NODE_ENV !== "production";
198
+
199
+ await configure({
200
+ sinks: {
201
+ console: getConsoleSink({
202
+ formatter: isDevelopment ? prettyFormatter : jsonLinesFormatter
203
+ })
204
+ }
205
+ });
206
+ ```
207
+
208
+ ### CI/CD Friendly
209
+
210
+ Automatically detect CI environments and adjust:
211
+
212
+ ```typescript
213
+ const isCI = process.env.CI === "true";
214
+
215
+ const formatter = getPrettyFormatter({
216
+ colors: !isCI,
217
+ icons: !isCI,
218
+ timestamp: isCI ? "datetime" : false
219
+ });
220
+ ```
221
+
222
+ ## Design Philosophy
223
+
224
+ @logtape/pretty is designed specifically for local development, prioritizing:
225
+
226
+ - **Visual Clarity**: Easy to scan and find important information
227
+ - **Minimal Noise**: Only show what's necessary
228
+ - **Developer Joy**: Make logs beautiful and enjoyable to read
229
+
230
+ ## License
231
+
232
+ MIT © 2024 Hong Minhee
233
+
234
+ ---
235
+
236
+ Made with ❤️ for developers who appreciate beautiful logs.
package/deno.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@logtape/pretty",
3
+ "version": "1.0.0-dev.231+227a7dc5",
4
+ "license": "MIT",
5
+ "exports": "./mod.ts",
6
+ "exclude": [
7
+ "dist/",
8
+ "coverage/",
9
+ "npm/",
10
+ ".dnt-import-map.json"
11
+ ],
12
+ "tasks": {
13
+ "build": "pnpm build",
14
+ "test": "deno test",
15
+ "test:node": {
16
+ "dependencies": [
17
+ "build"
18
+ ],
19
+ "command": "node --experimental-transform-types --test"
20
+ },
21
+ "test:bun": {
22
+ "dependencies": [
23
+ "build"
24
+ ],
25
+ "command": "bun test"
26
+ },
27
+ "test-all": {
28
+ "dependencies": [
29
+ "test",
30
+ "test:node",
31
+ "test:bun"
32
+ ]
33
+ }
34
+ }
35
+ }
@@ -0,0 +1,30 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target, mod));
22
+
23
+ //#endregion
24
+
25
+ Object.defineProperty(exports, '__toESM', {
26
+ enumerable: true,
27
+ get: function () {
28
+ return __toESM;
29
+ }
30
+ });