https://github.com/jayemscript/pretty-log-tagged
Make console logs readable with clean, structured, tag-based output.
https://github.com/jayemscript/pretty-log-tagged
console console-log javascript logging nodejs npm-package pretty-print typescript
Last synced: about 18 hours ago
JSON representation
Make console logs readable with clean, structured, tag-based output.
- Host: GitHub
- URL: https://github.com/jayemscript/pretty-log-tagged
- Owner: jayemscript
- License: mit
- Created: 2026-04-28T05:32:31.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2026-04-28T08:21:43.000Z (about 2 months ago)
- Last Synced: 2026-04-28T08:24:35.992Z (about 2 months ago)
- Topics: console, console-log, javascript, logging, nodejs, npm-package, pretty-print, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/pretty-log-tagged
- Size: 130 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE
- Security: docs/SECURITY.md
Awesome Lists containing this project
README
# pretty-log-tagged
Make console logs readable with clean, structured, tag-based output.
[](https://www.npmjs.com/package/pretty-log-tagged)
[](https://www.npmjs.com/package/pretty-log-tagged)
[](./LICENSE)
## The Problem
```ts
console.log(`User login: ${JSON.stringify(user)}`);
console.log(`[PAYMENT] ${JSON.stringify(payload)}`);
console.log(`[DB] Query took ${ms}ms`);
```
Hard to scan. No structure. No color. Every log looks the same.
## The Solution
```ts
clog.user(user);
clog.payment(payload);
clog.db(`Query took ${ms}ms`);
```
Each log line gets a colored tag, a timestamp, and formatted output automatically.
## Installation
```bash
npm install pretty-log-tagged
```
## Usage
```ts
import { clog } from 'pretty-log-tagged';
clog.user({ id: 1, name: 'Jay' });
clog.error('Something went wrong');
clog.payment({ amount: 99.99, currency: 'USD' });
clog.server('Listening on port 3000');
clog.db({ query: 'SELECT *', table: 'users' });
clog.auth({ token: 'Bearer ...' });
```
The dot notation is the tag. Any property you access becomes the label of that log line. All built-in tags are pre-styled, and any unknown tag falls back to a default style automatically.
```ts
clog.anything('works too');
clog.myCustomTag({ whatever: true });
```
## Built-in Tags
| Tag | Console Method |
|------------|----------------|
| `info` | console.info |
| `success` | console.log |
| `warn` | console.warn |
| `error` | console.error |
| `debug` | console.debug |
| `user` | console.log |
| `auth` | console.log |
| `db` | console.log |
| `api` | console.log |
| `server` | console.log |
| `request` | console.log |
| `response` | console.log |
| `cache` | console.log |
| `job` | console.log |
| `event` | console.log |
| `mail` | console.log |
| `payment` | console.log |
| `socket` | console.log |
| `test` | console.log |
## Custom Logger
Need your own tags or want to silence logs in tests? Use `createLogger`:
```ts
import { createLogger } from 'pretty-log-tagged';
const log = createLogger({
timestamp: true, // show ISO timestamp, default: true
silent: false, // suppress all output, default: false
tags: {
stripe: { fg: 'black', bg: 'brightGreen', level: 'log' },
redis: { fg: 'white', bg: 'red', level: 'warn' },
},
});
log.stripe({ event: 'charge.succeeded' });
log.redis('Cache miss');
```
Silence all output in test environments:
```ts
const log = createLogger({ silent: process.env.NODE_ENV === 'test' });
```
## Options
| Option | Type | Default | Description |
|-------------|-----------|---------|-----------------------------------|
| `timestamp` | `boolean` | `true` | Prepend ISO timestamp to each log |
| `silent` | `boolean` | `false` | Suppress all output |
| `tags` | `object` | `{}` | Add or override tag definitions |
## Tag Config
Each entry in `tags` accepts:
```ts
{
fg: FgColor, // foreground color
bg: BgColor, // background color
level: 'log' | 'info' | 'warn' | 'error' | 'debug'
}
```
Available colors: `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white`, `gray`, and their `bright` variants — `brightRed`, `brightGreen`, `brightBlue`, etc.
## TypeScript
Fully typed. The default `clog` instance and any instance from `createLogger` are typed with all built-in tags. Custom tags are accessible via string indexing.
```ts
import { clog, createLogger, PrettyLogger, LoggerOptions } from 'pretty-log-tagged';
```
## License
MIT