hazo_logs 1.0.9 → 1.0.10

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 CHANGED
@@ -185,14 +185,32 @@ import { createLogApiHandler } from 'hazo_logs/ui/server';
185
185
 
186
186
  **Note**: The `hazo_logs/server` and `hazo_logs/ui/server` imports use the `server-only` package and will throw an error if accidentally imported in client bundles. This prevents Next.js build errors from Node.js APIs (`fs`, `async_hooks`) being bundled for the browser.
187
187
 
188
- **Next.js 16 Turbopack Compatibility**: As of v1.0.9, hazo_logs is fully compatible with Next.js 16 Turbopack. All server-only modules are lazy-loaded to prevent static analysis issues during bundling.
188
+ **Next.js 16+ Turbopack Compatibility**: As of v1.0.10, hazo_logs uses **conditional exports** in `package.json` to automatically serve a client-safe bundle to browser environments. When bundlers (Next.js Turbopack, Webpack, etc.) resolve `hazo_logs`, they automatically receive:
189
+ - **Browser/Client**: A lightweight console-only logger with zero Node.js dependencies
190
+ - **Node.js/Server**: The full winston-based logger with file transports
191
+
192
+ This eliminates "Can't resolve 'fs'" errors completely without requiring any special import paths for basic logging.
189
193
 
190
194
  ### Tailwind CSS Setup Required
191
195
 
192
- The log viewer UI uses dynamic Tailwind classes that would be purged during build. You **must** configure both:
196
+ The log viewer UI uses dynamic Tailwind classes that would be purged during build.
197
+
198
+ #### Tailwind v4 Setup
199
+
200
+ Add the `@source` directive to your `globals.css` to enable Tailwind to scan hazo_logs classes:
201
+
202
+ ```css
203
+ @import "tailwindcss";
204
+
205
+ /* Required: Enable Tailwind to scan hazo_logs package classes */
206
+ @source "../node_modules/hazo_logs/dist";
207
+ ```
208
+
209
+ **Why this is needed:** Tailwind v4's JIT compiler doesn't scan `node_modules/` by default. Without this directive, hover states and interactive styles will be invisible.
210
+
211
+ #### Tailwind v3 Setup
193
212
 
194
- 1. **Content path**: So Tailwind scans the hazo_logs component files
195
- 2. **Safelist**: To preserve dynamically-constructed classes
213
+ Configure both the content path and safelist:
196
214
 
197
215
  ```typescript
198
216
  import { tailwindSafelist, tailwindContentPath } from 'hazo_logs/tailwind';
@@ -528,14 +546,15 @@ Error: Module not found: Can't resolve 'async_hooks'
528
546
  Error: Module not found: Can't resolve 'fs'
529
547
  ```
530
548
 
531
- This error occurred in earlier versions when server-only code was imported in client components. **As of v1.0.9, this is fixed** - the library now uses lazy loading for all server-only modules, making it fully compatible with Next.js 16 Turbopack.
549
+ This error occurred in earlier versions when server-only code was imported in client components. **As of v1.0.10, this is fully fixed** - the library now uses **conditional exports** in `package.json`, so bundlers automatically receive a client-safe bundle with zero Node.js dependencies.
532
550
 
533
551
  If you still see this error:
534
552
 
535
- 1. **Upgrade hazo_logs**: Run `npm update hazo_logs` to get the latest version
536
- 2. **For logging in client components**: Use `createClientLogger` from `hazo_logs/ui`
537
- 3. **For server-only modules**: Import from `hazo_logs/server` instead of `hazo_logs`
538
- 4. **For universal code**: The base `hazo_logs` import works on both client and server (returns console logger on client)
553
+ 1. **Upgrade hazo_logs**: Run `npm update hazo_logs` to get v1.0.10 or later
554
+ 2. **Clear build cache**: Run `rm -rf .next` and rebuild
555
+ 3. **For logging in client components**: The base `hazo_logs` import now works automatically (returns console logger on client)
556
+ 4. **For client logging that posts to server**: Use `createClientLogger` from `hazo_logs/ui`
557
+ 5. **For full server capabilities**: Import from `hazo_logs/server` for file logging, sessions, and context
539
558
 
540
559
  ### hazo_ui missing errors
541
560
 
@@ -0,0 +1,55 @@
1
+ /**
2
+ * hazo_logs/client - Client-safe logging module
3
+ *
4
+ * This module contains ONLY client-safe code with NO imports that could
5
+ * lead to Node.js modules (winston, fs, path, etc.).
6
+ *
7
+ * Used automatically when bundlers resolve 'hazo_logs' for browser targets.
8
+ */
9
+ import type { Logger, LogData, LogLevel } from '../lib/types.js';
10
+ /**
11
+ * Console-based logger for client-side use
12
+ * Provides basic logging that outputs to browser console
13
+ */
14
+ export declare class ConsoleLogger implements Logger {
15
+ private packageName;
16
+ private minLevel;
17
+ constructor(packageName: string, minLevel?: LogLevel);
18
+ private shouldLog;
19
+ private formatMessage;
20
+ error(message: string, data?: LogData): void;
21
+ warn(message: string, data?: LogData): void;
22
+ info(message: string, data?: LogData): void;
23
+ debug(message: string, data?: LogData): void;
24
+ }
25
+ /**
26
+ * Create a client-side logger that outputs to browser console
27
+ *
28
+ * @param packageName - Name of the package (e.g., "hazo_auth", "my_app")
29
+ * @returns Logger instance that logs to console
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * import { createLogger } from 'hazo_logs';
34
+ *
35
+ * const logger = createLogger('my_app');
36
+ * logger.info('Application started');
37
+ * ```
38
+ *
39
+ * Note: For full server capabilities (file logging, context), use:
40
+ * ```typescript
41
+ * import { createLogger } from 'hazo_logs/server';
42
+ * ```
43
+ */
44
+ export declare function createLogger(packageName: string): Logger;
45
+ /**
46
+ * Async version - same as createLogger on client
47
+ * Provided for API compatibility with server version
48
+ */
49
+ export declare function createLoggerAsync(packageName: string): Promise<Logger>;
50
+ /**
51
+ * No-op on client - server preloading not applicable
52
+ */
53
+ export declare function preloadServerLogger(): Promise<void>;
54
+ export type { Logger, LogLevel, LogData, LogEntry, LogContext, HazoLogConfig, PackageLoggerOptions, LogSource, } from '../lib/types.js';
55
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AASjE;;;GAGG;AACH,qBAAa,aAAc,YAAW,MAAM;IAC1C,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAW;gBAEf,WAAW,EAAE,MAAM,EAAE,QAAQ,GAAE,QAAkB;IAK7D,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,aAAa;IAKrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI;IAM5C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI;IAM3C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI;IAM3C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI;CAK7C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAE5E;AAED;;GAEG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEzD;AAGD,YAAY,EACV,MAAM,EACN,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,UAAU,EACV,aAAa,EACb,oBAAoB,EACpB,SAAS,GACV,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * hazo_logs/client - Client-safe logging module
3
+ *
4
+ * This module contains ONLY client-safe code with NO imports that could
5
+ * lead to Node.js modules (winston, fs, path, etc.).
6
+ *
7
+ * Used automatically when bundlers resolve 'hazo_logs' for browser targets.
8
+ */
9
+ const LOG_LEVEL_PRIORITY = {
10
+ error: 0,
11
+ warn: 1,
12
+ info: 2,
13
+ debug: 3,
14
+ };
15
+ /**
16
+ * Console-based logger for client-side use
17
+ * Provides basic logging that outputs to browser console
18
+ */
19
+ export class ConsoleLogger {
20
+ packageName;
21
+ minLevel;
22
+ constructor(packageName, minLevel = 'debug') {
23
+ this.packageName = packageName;
24
+ this.minLevel = minLevel;
25
+ }
26
+ shouldLog(level) {
27
+ return LOG_LEVEL_PRIORITY[level] <= LOG_LEVEL_PRIORITY[this.minLevel];
28
+ }
29
+ formatMessage(level, message) {
30
+ const timestamp = new Date().toISOString();
31
+ return `[${timestamp}] [${level.toUpperCase()}] [${this.packageName}] ${message}`;
32
+ }
33
+ error(message, data) {
34
+ if (this.shouldLog('error')) {
35
+ console.error(this.formatMessage('error', message), data ?? '');
36
+ }
37
+ }
38
+ warn(message, data) {
39
+ if (this.shouldLog('warn')) {
40
+ console.warn(this.formatMessage('warn', message), data ?? '');
41
+ }
42
+ }
43
+ info(message, data) {
44
+ if (this.shouldLog('info')) {
45
+ console.info(this.formatMessage('info', message), data ?? '');
46
+ }
47
+ }
48
+ debug(message, data) {
49
+ if (this.shouldLog('debug')) {
50
+ console.debug(this.formatMessage('debug', message), data ?? '');
51
+ }
52
+ }
53
+ }
54
+ /**
55
+ * Create a client-side logger that outputs to browser console
56
+ *
57
+ * @param packageName - Name of the package (e.g., "hazo_auth", "my_app")
58
+ * @returns Logger instance that logs to console
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * import { createLogger } from 'hazo_logs';
63
+ *
64
+ * const logger = createLogger('my_app');
65
+ * logger.info('Application started');
66
+ * ```
67
+ *
68
+ * Note: For full server capabilities (file logging, context), use:
69
+ * ```typescript
70
+ * import { createLogger } from 'hazo_logs/server';
71
+ * ```
72
+ */
73
+ export function createLogger(packageName) {
74
+ return new ConsoleLogger(packageName);
75
+ }
76
+ /**
77
+ * Async version - same as createLogger on client
78
+ * Provided for API compatibility with server version
79
+ */
80
+ export async function createLoggerAsync(packageName) {
81
+ return new ConsoleLogger(packageName);
82
+ }
83
+ /**
84
+ * No-op on client - server preloading not applicable
85
+ */
86
+ export async function preloadServerLogger() {
87
+ // No-op on client
88
+ }
89
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,MAAM,kBAAkB,GAA6B;IACnD,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CA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AI,EAAE,CAAC,CAAC;QAChE,CAAC;IACH,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,IAAc;QACnC,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC;YAC5B,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,OAAO,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;CACF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,UAAU,YAAY,CAAC,WAAmB;IAC9C,OAAO,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;AACxC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,WAAmB;IACzD,OAAO,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB;IACvC,kBAAkB;AACpB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hazo_logs",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Logger for hazo packages - Winston wrapper with singleton pattern",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -8,14 +8,22 @@
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/index.d.ts",
11
+ "browser": "./dist/client/index.js",
12
+ "node": "./dist/index.js",
11
13
  "import": "./dist/index.js",
12
- "require": "./dist/index.js"
14
+ "require": "./dist/index.js",
15
+ "default": "./dist/client/index.js"
13
16
  },
14
17
  "./server": {
15
18
  "types": "./dist/server.d.ts",
16
19
  "import": "./dist/server.js",
17
20
  "require": "./dist/server.js"
18
21
  },
22
+ "./client": {
23
+ "types": "./dist/client/index.d.ts",
24
+ "import": "./dist/client/index.js",
25
+ "require": "./dist/client/index.js"
26
+ },
19
27
  "./ui": {
20
28
  "types": "./dist/ui/index.d.ts",
21
29
  "import": "./dist/ui/index.js",