@rdrudra99/hardlog 0.1.4 → 1.1.1
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 +74 -21
- package/dist/index.d.ts +8 -46
- package/dist/index.js +8 -48
- package/dist/logger.d.ts +4 -4
- package/dist/logger.js +17 -19
- package/package.json +9 -5
package/README.md
CHANGED
|
@@ -1,8 +1,41 @@
|
|
|
1
|
-
#
|
|
1
|
+
# hardlogger
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
## ⚠️ Package Moved
|
|
4
|
+
|
|
5
|
+
**This package (`@rdrudra99/hardlog`) has been renamed to `hardlogger`.**
|
|
6
|
+
|
|
7
|
+
### Migration Instructions
|
|
8
|
+
|
|
9
|
+
**For new users:**
|
|
10
|
+
```bash
|
|
11
|
+
npm install hardlogger
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
**For existing users:**
|
|
15
|
+
```bash
|
|
16
|
+
# Remove the old scoped package
|
|
17
|
+
npm uninstall @rdrudra99/hardlog
|
|
18
|
+
|
|
19
|
+
# Install the new package
|
|
20
|
+
npm install hardlogger
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Update your imports:**
|
|
24
|
+
```typescript
|
|
25
|
+
// Old (still works but deprecated)
|
|
26
|
+
import log from '@rdrudra99/hardlog';
|
|
27
|
+
|
|
28
|
+
// New (recommended)
|
|
29
|
+
import log from 'hardlogger';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
> **Note:** This package now acts as a compatibility layer only and simply re-exports everything from `hardlogger`. All future development and updates will happen in the `hardlogger` package.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
[](https://www.npmjs.com/package/hardlogger)
|
|
37
|
+
[](https://www.npmjs.com/package/hardlogger)
|
|
38
|
+
[](https://github.com/Rdrudra99/hardlog/blob/main/LICENSE)
|
|
6
39
|
[](https://www.typescriptlang.org/)
|
|
7
40
|
|
|
8
41
|
Beautiful, colorful dev-only logging for Node.js and Browser with **zero configuration**.
|
|
@@ -16,25 +49,25 @@ Automatically detects your runtime environment and applies appropriate styling:
|
|
|
16
49
|
## Installation
|
|
17
50
|
|
|
18
51
|
```bash
|
|
19
|
-
bun add
|
|
52
|
+
bun add hardlogger
|
|
20
53
|
```
|
|
21
54
|
|
|
22
55
|
```bash
|
|
23
|
-
npm install
|
|
56
|
+
npm install hardlogger
|
|
24
57
|
```
|
|
25
58
|
|
|
26
59
|
```bash
|
|
27
|
-
yarn add
|
|
60
|
+
yarn add hardlogger
|
|
28
61
|
```
|
|
29
62
|
|
|
30
63
|
```bash
|
|
31
|
-
pnpm add
|
|
64
|
+
pnpm add hardlogger
|
|
32
65
|
```
|
|
33
66
|
|
|
34
67
|
## Basic Usage
|
|
35
68
|
|
|
36
69
|
```typescript
|
|
37
|
-
import log from '
|
|
70
|
+
import log from 'hardlogger';
|
|
38
71
|
|
|
39
72
|
log.success('Server started successfully!');
|
|
40
73
|
log.error('Database connection failed');
|
|
@@ -50,8 +83,28 @@ log.info('Listening on port 3000');
|
|
|
50
83
|
ℹ INFO Listening on port 3000
|
|
51
84
|
```
|
|
52
85
|
|
|
53
|
-
|
|
54
|
-
|
|
86
|
+
## 🧪 Before vs After
|
|
87
|
+
|
|
88
|
+
### 🖥️ Backend (Node.js / Express)
|
|
89
|
+
|
|
90
|
+
**Before**
|
|
91
|
+

|
|
92
|
+
|
|
93
|
+
**Before**<img width="1154" height="674" alt="screenzy-1768106259246" src="https://github.com/user-attachments/assets/1df6ed28-dc95-4be2-816f-7ef16ee035ac" />
|
|
94
|
+
**After**<img width="1154" height="674" alt="screenzy-1768106238474" src="https://github.com/user-attachments/assets/38ec2961-0d03-48a3-986d-dae1645fac39" />
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
### 🌐 Frontend (React / Next.js)
|
|
99
|
+
|
|
100
|
+
**Before**
|
|
101
|
+

|
|
102
|
+
|
|
103
|
+
**After**
|
|
104
|
+

|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
|
|
55
108
|
|
|
56
109
|
## Examples
|
|
57
110
|
|
|
@@ -59,7 +112,7 @@ log.info('Listening on port 3000');
|
|
|
59
112
|
|
|
60
113
|
```typescript
|
|
61
114
|
import express from 'express';
|
|
62
|
-
import log from '
|
|
115
|
+
import log from 'hardlogger';
|
|
63
116
|
|
|
64
117
|
const app = express();
|
|
65
118
|
const PORT = 3000;
|
|
@@ -78,7 +131,7 @@ app.listen(PORT, () => {
|
|
|
78
131
|
|
|
79
132
|
```typescript
|
|
80
133
|
// app/page.tsx
|
|
81
|
-
import log from '
|
|
134
|
+
import log from 'hardlogger';
|
|
82
135
|
|
|
83
136
|
export default async function HomePage() {
|
|
84
137
|
// This runs on the server
|
|
@@ -97,7 +150,7 @@ export default async function HomePage() {
|
|
|
97
150
|
'use client';
|
|
98
151
|
|
|
99
152
|
import { useEffect } from 'react';
|
|
100
|
-
import log from '
|
|
153
|
+
import log from 'hardlogger';
|
|
101
154
|
|
|
102
155
|
export default function ClientComponent() {
|
|
103
156
|
useEffect(() => {
|
|
@@ -122,7 +175,7 @@ export default function ClientComponent() {
|
|
|
122
175
|
```typescript
|
|
123
176
|
// pages/index.tsx
|
|
124
177
|
import { GetServerSideProps } from 'next';
|
|
125
|
-
import log from '
|
|
178
|
+
import log from 'hardlogger';
|
|
126
179
|
|
|
127
180
|
export const getServerSideProps: GetServerSideProps = async () => {
|
|
128
181
|
log.info('Fetching data for page');
|
|
@@ -141,7 +194,7 @@ export default function Page({ data }) {
|
|
|
141
194
|
### Browser-Only App
|
|
142
195
|
|
|
143
196
|
```typescript
|
|
144
|
-
import log from '
|
|
197
|
+
import log from 'hardlogger';
|
|
145
198
|
|
|
146
199
|
document.addEventListener('DOMContentLoaded', () => {
|
|
147
200
|
log.success('DOM loaded');
|
|
@@ -205,7 +258,7 @@ log.config({
|
|
|
205
258
|
#### Enable timestamps
|
|
206
259
|
|
|
207
260
|
```typescript
|
|
208
|
-
import log from '
|
|
261
|
+
import log from 'hardlogger';
|
|
209
262
|
|
|
210
263
|
log.config({ showTimestamp: true });
|
|
211
264
|
|
|
@@ -216,7 +269,7 @@ log.info('Server started');
|
|
|
216
269
|
#### Force enable in production (NOT RECOMMENDED)
|
|
217
270
|
|
|
218
271
|
```typescript
|
|
219
|
-
import log from '
|
|
272
|
+
import log from 'hardlogger';
|
|
220
273
|
|
|
221
274
|
// ⚠️ Only do this if you understand the implications
|
|
222
275
|
log.config({ enabled: true });
|
|
@@ -225,7 +278,7 @@ log.config({ enabled: true });
|
|
|
225
278
|
#### Chain configuration
|
|
226
279
|
|
|
227
280
|
```typescript
|
|
228
|
-
import log from '
|
|
281
|
+
import log from 'hardlogger';
|
|
229
282
|
|
|
230
283
|
log
|
|
231
284
|
.config({ showTimestamp: true })
|
|
@@ -282,7 +335,7 @@ log.config({ enabled: true });
|
|
|
282
335
|
This package is written in TypeScript and ships with type definitions.
|
|
283
336
|
|
|
284
337
|
```typescript
|
|
285
|
-
import log, { LoggerConfig } from '
|
|
338
|
+
import log, { LoggerConfig } from 'hardlogger';
|
|
286
339
|
|
|
287
340
|
const config: LoggerConfig = {
|
|
288
341
|
enabled: true,
|
|
@@ -333,7 +386,7 @@ Most logging libraries are either:
|
|
|
333
386
|
- Require configuration
|
|
334
387
|
- Not production-safe by default
|
|
335
388
|
|
|
336
|
-
|
|
389
|
+
`hardlogger` is designed specifically for the **developer experience** during development, with:
|
|
337
390
|
- Automatic environment detection
|
|
338
391
|
- Zero configuration
|
|
339
392
|
- Production safety built-in
|
package/dist/index.d.ts
CHANGED
|
@@ -1,49 +1,11 @@
|
|
|
1
|
-
import type { LoggerConfig } from './types.js';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* @deprecated This package has been renamed to 'hardlogger'.
|
|
3
|
+
* Please update your dependencies:
|
|
4
|
+
* - Remove: npm uninstall @rdrudra99/hardlog
|
|
5
|
+
* - Install: npm install hardlogger
|
|
6
|
+
* - Update imports: import log from 'hardlogger';
|
|
4
7
|
*
|
|
5
|
-
*
|
|
6
|
-
* Disabled by default in production (NODE_ENV === 'production').
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* import log from 'hardlog';
|
|
11
|
-
*
|
|
12
|
-
* log.success('Server started successfully!');
|
|
13
|
-
* log.error('Database connection failed');
|
|
14
|
-
* log.warn('Missing environment variable');
|
|
15
|
-
* log.info('Listening on port 3000');
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* // Configure logger
|
|
21
|
-
* import log from 'hardlog';
|
|
22
|
-
*
|
|
23
|
-
* log.config({ enabled: true, showTimestamp: true });
|
|
24
|
-
* ```
|
|
8
|
+
* This package now re-exports everything from 'hardlogger' for backward compatibility.
|
|
25
9
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* Log a success message
|
|
29
|
-
*/
|
|
30
|
-
success: (message: string) => void;
|
|
31
|
-
/**
|
|
32
|
-
* Log an error message
|
|
33
|
-
*/
|
|
34
|
-
error: (message: string) => void;
|
|
35
|
-
/**
|
|
36
|
-
* Log a warning message
|
|
37
|
-
*/
|
|
38
|
-
warn: (message: string) => void;
|
|
39
|
-
/**
|
|
40
|
-
* Log an info message
|
|
41
|
-
*/
|
|
42
|
-
info: (message: string) => void;
|
|
43
|
-
/**
|
|
44
|
-
* Configure logger options
|
|
45
|
-
*/
|
|
46
|
-
config: (options: LoggerConfig) => /*elided*/ any;
|
|
47
|
-
};
|
|
48
|
-
export default log;
|
|
49
|
-
export type { LoggerConfig };
|
|
10
|
+
export { default } from 'hardlogger';
|
|
11
|
+
export type { LoggerConfig } from 'hardlogger';
|
package/dist/index.js
CHANGED
|
@@ -1,51 +1,11 @@
|
|
|
1
|
-
import { logger } from './logger.js';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
2
|
+
* @deprecated This package has been renamed to 'hardlogger'.
|
|
3
|
+
* Please update your dependencies:
|
|
4
|
+
* - Remove: npm uninstall @rdrudra99/hardlog
|
|
5
|
+
* - Install: npm install hardlogger
|
|
6
|
+
* - Update imports: import log from 'hardlogger';
|
|
4
7
|
*
|
|
5
|
-
*
|
|
6
|
-
* Disabled by default in production (NODE_ENV === 'production').
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* import log from 'hardlog';
|
|
11
|
-
*
|
|
12
|
-
* log.success('Server started successfully!');
|
|
13
|
-
* log.error('Database connection failed');
|
|
14
|
-
* log.warn('Missing environment variable');
|
|
15
|
-
* log.info('Listening on port 3000');
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* // Configure logger
|
|
21
|
-
* import log from 'hardlog';
|
|
22
|
-
*
|
|
23
|
-
* log.config({ enabled: true, showTimestamp: true });
|
|
24
|
-
* ```
|
|
8
|
+
* This package now re-exports everything from 'hardlogger' for backward compatibility.
|
|
25
9
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* Log a success message
|
|
29
|
-
*/
|
|
30
|
-
success: (message) => logger.success(message),
|
|
31
|
-
/**
|
|
32
|
-
* Log an error message
|
|
33
|
-
*/
|
|
34
|
-
error: (message) => logger.error(message),
|
|
35
|
-
/**
|
|
36
|
-
* Log a warning message
|
|
37
|
-
*/
|
|
38
|
-
warn: (message) => logger.warn(message),
|
|
39
|
-
/**
|
|
40
|
-
* Log an info message
|
|
41
|
-
*/
|
|
42
|
-
info: (message) => logger.info(message),
|
|
43
|
-
/**
|
|
44
|
-
* Configure logger options
|
|
45
|
-
*/
|
|
46
|
-
config: (options) => {
|
|
47
|
-
logger.configure(options);
|
|
48
|
-
return log;
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
export default log;
|
|
10
|
+
// Re-export everything from hardlogger
|
|
11
|
+
export { default } from 'hardlogger';
|
package/dist/logger.d.ts
CHANGED
|
@@ -29,19 +29,19 @@ declare class Logger {
|
|
|
29
29
|
/**
|
|
30
30
|
* Log success message
|
|
31
31
|
*/
|
|
32
|
-
success(
|
|
32
|
+
success(...args: any[]): void;
|
|
33
33
|
/**
|
|
34
34
|
* Log error message
|
|
35
35
|
*/
|
|
36
|
-
error(
|
|
36
|
+
error(...args: any[]): void;
|
|
37
37
|
/**
|
|
38
38
|
* Log warning message
|
|
39
39
|
*/
|
|
40
|
-
warn(
|
|
40
|
+
warn(...args: any[]): void;
|
|
41
41
|
/**
|
|
42
42
|
* Log info message
|
|
43
43
|
*/
|
|
44
|
-
info(
|
|
44
|
+
info(...args: any[]): void;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* Singleton logger instance
|
package/dist/logger.js
CHANGED
|
@@ -71,12 +71,12 @@ class Logger {
|
|
|
71
71
|
/**
|
|
72
72
|
* Log message in Node.js with ANSI colors
|
|
73
73
|
*/
|
|
74
|
-
logNode(level,
|
|
74
|
+
logNode(level, ...args) {
|
|
75
75
|
try {
|
|
76
76
|
const cfg = LOG_CONFIG[level];
|
|
77
77
|
const timestamp = this.config.showTimestamp ? `${this.getTimestamp()} ` : '';
|
|
78
|
-
const
|
|
79
|
-
console.log(
|
|
78
|
+
const prefix = `${cfg.color}${cfg.symbol} ${cfg.label.padEnd(10)}${ANSI_COLORS.reset} ${timestamp}`;
|
|
79
|
+
console.log(prefix, ...args);
|
|
80
80
|
}
|
|
81
81
|
catch (_a) {
|
|
82
82
|
// Fail silently
|
|
@@ -85,12 +85,12 @@ class Logger {
|
|
|
85
85
|
/**
|
|
86
86
|
* Log message in browser with CSS styling
|
|
87
87
|
*/
|
|
88
|
-
logBrowser(level,
|
|
88
|
+
logBrowser(level, ...args) {
|
|
89
89
|
try {
|
|
90
90
|
const cfg = LOG_CONFIG[level];
|
|
91
91
|
const timestamp = this.config.showTimestamp ? `${this.getTimestamp()} ` : '';
|
|
92
92
|
const label = `${cfg.symbol} ${cfg.label}`;
|
|
93
|
-
console.log(`%c${label}%c ${timestamp}
|
|
93
|
+
console.log(`%c${label}%c ${timestamp}`, BROWSER_STYLES[level], '', ...args);
|
|
94
94
|
}
|
|
95
95
|
catch (_a) {
|
|
96
96
|
// Fail silently
|
|
@@ -99,23 +99,21 @@ class Logger {
|
|
|
99
99
|
/**
|
|
100
100
|
* Core log method - routes to appropriate handler
|
|
101
101
|
*/
|
|
102
|
-
log(level,
|
|
102
|
+
log(level, ...args) {
|
|
103
103
|
// Don't log if disabled
|
|
104
104
|
if (!this.config.enabled) {
|
|
105
105
|
return;
|
|
106
106
|
}
|
|
107
107
|
try {
|
|
108
|
-
// Convert message to string safely
|
|
109
|
-
const msg = String(message !== null && message !== void 0 ? message : '');
|
|
110
108
|
if (this.runtime === 'node') {
|
|
111
|
-
this.logNode(level,
|
|
109
|
+
this.logNode(level, ...args);
|
|
112
110
|
}
|
|
113
111
|
else if (this.runtime === 'browser') {
|
|
114
|
-
this.logBrowser(level,
|
|
112
|
+
this.logBrowser(level, ...args);
|
|
115
113
|
}
|
|
116
114
|
else {
|
|
117
115
|
// Fallback to plain console.log
|
|
118
|
-
console.log(`[${level.toUpperCase()}]`,
|
|
116
|
+
console.log(`[${level.toUpperCase()}]`, ...args);
|
|
119
117
|
}
|
|
120
118
|
}
|
|
121
119
|
catch (_a) {
|
|
@@ -125,26 +123,26 @@ class Logger {
|
|
|
125
123
|
/**
|
|
126
124
|
* Log success message
|
|
127
125
|
*/
|
|
128
|
-
success(
|
|
129
|
-
this.log('success',
|
|
126
|
+
success(...args) {
|
|
127
|
+
this.log('success', ...args);
|
|
130
128
|
}
|
|
131
129
|
/**
|
|
132
130
|
* Log error message
|
|
133
131
|
*/
|
|
134
|
-
error(
|
|
135
|
-
this.log('error',
|
|
132
|
+
error(...args) {
|
|
133
|
+
this.log('error', ...args);
|
|
136
134
|
}
|
|
137
135
|
/**
|
|
138
136
|
* Log warning message
|
|
139
137
|
*/
|
|
140
|
-
warn(
|
|
141
|
-
this.log('warn',
|
|
138
|
+
warn(...args) {
|
|
139
|
+
this.log('warn', ...args);
|
|
142
140
|
}
|
|
143
141
|
/**
|
|
144
142
|
* Log info message
|
|
145
143
|
*/
|
|
146
|
-
info(
|
|
147
|
-
this.log('info',
|
|
144
|
+
info(...args) {
|
|
145
|
+
this.log('info', ...args);
|
|
148
146
|
}
|
|
149
147
|
}
|
|
150
148
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rdrudra99/hardlog",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.1.1",
|
|
4
|
+
"description": "[DEPRECATED] This package has been renamed to 'hardlogger'. Please use 'hardlogger' instead.",
|
|
5
|
+
"deprecated": "⚠️ This package has been renamed to 'hardlogger'. Install using: npm install hardlogger",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
7
8
|
"files": [
|
|
@@ -43,12 +44,15 @@
|
|
|
43
44
|
"license": "MIT",
|
|
44
45
|
"repository": {
|
|
45
46
|
"type": "git",
|
|
46
|
-
"url": "git+https://github.com/Rdrudra99/
|
|
47
|
+
"url": "git+https://github.com/Rdrudra99/hardlogger.git"
|
|
47
48
|
},
|
|
48
49
|
"bugs": {
|
|
49
|
-
"url": "https://github.com/Rdrudra99/
|
|
50
|
+
"url": "https://github.com/Rdrudra99/hardlogger/issues"
|
|
51
|
+
},
|
|
52
|
+
"homepage": "https://github.com/Rdrudra99/hardlogger#readme",
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"hardlogger": "^1.1.1"
|
|
50
55
|
},
|
|
51
|
-
"homepage": "https://github.com/Rdrudra99/hardlog#readme",
|
|
52
56
|
"devDependencies": {
|
|
53
57
|
"@types/node": "^25.0.3",
|
|
54
58
|
"typescript": "^5.3.3"
|