Skip to content

Commit 4399637

Browse files
committed
feat: added documentation
1 parent 8016775 commit 4399637

3 files changed

Lines changed: 179 additions & 0 deletions

File tree

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,88 @@
11
# pretty-log
2+
23
Make console logs readable with clean, structured, tag-based output.
4+
5+
## Installation
6+
7+
```bash
8+
npm install pretty-log
9+
```
10+
11+
## Usage
12+
13+
```ts
14+
import { clog } from 'pretty-log';
15+
16+
clog.user({ id: 1, name: 'Jay' });
17+
clog.error('Something went wrong');
18+
clog.payment({ amount: 99.99, currency: 'USD' });
19+
clog.server('Listening on port 3000');
20+
```
21+
22+
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.
23+
24+
## Built-in Tags
25+
26+
| Tag | Console Method |
27+
|-----------|----------------|
28+
| info | console.info |
29+
| success | console.log |
30+
| warn | console.warn |
31+
| error | console.error |
32+
| debug | console.debug |
33+
| user | console.log |
34+
| auth | console.log |
35+
| db | console.log |
36+
| api | console.log |
37+
| server | console.log |
38+
| request | console.log |
39+
| response | console.log |
40+
| cache | console.log |
41+
| job | console.log |
42+
| event | console.log |
43+
| mail | console.log |
44+
| payment | console.log |
45+
| socket | console.log |
46+
| test | console.log |
47+
48+
## Custom Logger
49+
50+
```ts
51+
import { createLogger } from 'pretty-log';
52+
53+
const log = createLogger({
54+
timestamp: true, // show ISO timestamp, default: true
55+
silent: false, // suppress all output, default: false
56+
tags: {
57+
stripe: { fg: 'black', bg: 'brightGreen', level: 'log' },
58+
redis: { fg: 'white', bg: 'red', level: 'warn' },
59+
},
60+
});
61+
62+
log.stripe({ event: 'charge.succeeded' });
63+
log.redis('Cache miss');
64+
```
65+
66+
## Options
67+
68+
| Option | Type | Default | Description |
69+
|-------------|---------|---------|------------------------------------|
70+
| `timestamp` | boolean | `true` | Prepend ISO timestamp to each log |
71+
| `silent` | boolean | `false` | Suppress all output |
72+
| `tags` | object | `{}` | Add or override tag definitions |
73+
74+
## Tag Config
75+
76+
Each tag entry accepts the following fields:
77+
78+
```ts
79+
{
80+
fg: FgColor, // foreground color
81+
bg: BgColor, // background color
82+
level: 'log' | 'info' | 'warn' | 'error' | 'debug'
83+
}
84+
```
85+
86+
## License
87+
88+
MIT

docs/CONTRIBUTING.md

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Contributing
2+
3+
Contributions are welcome. Please read this guide before submitting a pull request.
4+
5+
## Getting Started
6+
7+
```bash
8+
git clone https://github.com/jayemscript/pretty-log.git
9+
cd pretty-log
10+
npm install
11+
```
12+
13+
## Development
14+
15+
Run the tests:
16+
17+
```bash
18+
npm test
19+
```
20+
21+
Type check without building:
22+
23+
```bash
24+
npm run lint
25+
```
26+
27+
Build the package:
28+
29+
```bash
30+
npm run build
31+
```
32+
33+
## Project Structure
34+
35+
```
36+
src/
37+
index.ts - public exports
38+
logger.ts - core logger and createLogger factory
39+
lib/
40+
tags.ts - built-in tag definitions
41+
utils/
42+
colors.ts - ANSI color codes
43+
formatter.ts - timestamp, label, and data formatting
44+
test/
45+
logger.test.ts - all tests
46+
```
47+
48+
## Guidelines
49+
50+
- Keep changes focused. One feature or fix per pull request.
51+
- Add or update tests for any changed behavior.
52+
- Make sure `npm test` and `npm run lint` pass before submitting.
53+
- Follow the existing code style — strict TypeScript, no external runtime dependencies.
54+
55+
## Adding a Built-in Tag
56+
57+
Open `src/lib/tags.ts` and add an entry to `DEFAULT_TAGS`:
58+
59+
```ts
60+
mytag: { fg: 'black', bg: 'brightCyan', level: 'log' },
61+
```
62+
63+
That is all that is needed. The Proxy in `logger.ts` picks it up automatically.
64+
65+
## Reporting Issues
66+
67+
Open an issue on GitHub with a clear description and a minimal reproduction if possible.
68+
69+
## License
70+
71+
By contributing, you agree that your contributions will be licensed under the MIT license.

docs/SECURITY.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
Only the latest version of pretty-log receives security updates.
6+
7+
| Version | Supported |
8+
|---------|-----------|
9+
| latest | yes |
10+
| older | no |
11+
12+
## Reporting a Vulnerability
13+
14+
If you discover a security vulnerability, do not open a public GitHub issue.
15+
16+
Instead, report it privately by emailing the maintainer directly. Include as much detail as possible — a description of the issue, steps to reproduce, and any potential impact.
17+
18+
You can expect an acknowledgment within 48 hours and a resolution or status update within 7 days.
19+
20+
## Scope
21+
22+
pretty-log is a logging utility with no network access, no file system writes, and no external runtime dependencies. The attack surface is limited to console output formatting. That said, any confirmed vulnerability will be taken seriously and patched promptly.

0 commit comments

Comments
 (0)