@nexload-sdk/logger 1.0.1 → 1.0.3

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/package.json CHANGED
@@ -1,14 +1,47 @@
1
1
  {
2
2
  "name": "@nexload-sdk/logger",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
+ "description": "High-performance, structured, and type-safe logging for JS/TS apps — powered by pino, with pretty output, env-integration, security redaction, and Next.js-friendly wrappers.",
5
+ "keywords": [
6
+ "logger",
7
+ "pino",
8
+ "typescript",
9
+ "logging",
10
+ "structured log",
11
+ "nextjs",
12
+ "nodejs",
13
+ "pretty print",
14
+ "redact",
15
+ "performance",
16
+ "observability"
17
+ ],
18
+ "homepage": "https://github.com/gecut/nexload-sdk/tree/main/packages/logger",
19
+ "bugs": {
20
+ "url": "https://github.com/gecut/nexload-sdk/issues"
21
+ },
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/gecut/nexload-sdk.git",
25
+ "directory": "packages/logger"
26
+ },
27
+ "author": {
28
+ "name": "S. MohammadMahdi Zamanian",
29
+ "url": "https://mm25zamanian.ir",
30
+ "email": "dev@mm25zamanian.ir"
31
+ },
32
+ "license": "MIT",
33
+ "type": "module",
4
34
  "exports": {
5
35
  ".": {
6
36
  "types": "./dist/index.d.ts",
7
37
  "default": "./dist/index.cjs"
8
38
  }
9
39
  },
10
- "license": "MIT",
11
- "type": "module",
40
+ "files": [
41
+ "dist",
42
+ "README.md",
43
+ "package.json"
44
+ ],
12
45
  "publishConfig": {
13
46
  "access": "public"
14
47
  },
@@ -16,12 +49,12 @@
16
49
  "@types/node": "^24.9.1",
17
50
  "eslint": "^9.38.0",
18
51
  "typescript": "5.9.3",
19
- "@nexload-sdk/eslint-config": "1.0.0",
20
- "@nexload-sdk/typescript-config": "1.0.0",
21
- "@nexload-sdk/bundler": "1.0.0"
52
+ "@nexload-sdk/typescript-config": "1.0.2",
53
+ "@nexload-sdk/eslint-config": "1.0.2",
54
+ "@nexload-sdk/bundler": "1.0.2"
22
55
  },
23
56
  "dependencies": {
24
- "@nexload-sdk/env": "^1.0.0",
57
+ "@nexload-sdk/env": "^1.0.2",
25
58
  "pino": "^10.0.0",
26
59
  "pino-pretty": "^13.1.2"
27
60
  },
@@ -1,10 +0,0 @@
1
-
2
- 
3
- > @nexload-sdk/logger@0.0.0 build /Users/mm25zamanian/Codes/nexload-sdk/packages/logger
4
- > node esbuild.config.mjs
5
-
6
- 1. Cleaning dist directory...
7
- 2. Building JS outputs (CJS & ESM) via esbuild...
8
- 3. Generating TypeScript declarations via tsc...
9
- Build successful!
10
-
@@ -1,13 +0,0 @@
1
-
2
- 
3
- > @nexload-sdk/logger@0.0.0 lint /Users/mm25zamanian/Codes/nexload-sdk/packages/logger
4
- > eslint .
5
-
6
- 
7
- /Users/mm25zamanian/Codes/nexload-sdk/packages/logger/index.ts
8
-  1:1 warning Unexpected console statement no-console
9
-  1:23 warning Newline required at end of file but not found @stylistic/eol-last
10
- 
11
- ✖ 2 problems (0 errors, 2 warnings)
12
-  0 errors and 1 warning potentially fixable with the `--fix` option.
13
- 
package/CHANGELOG.md DELETED
@@ -1,18 +0,0 @@
1
- # @nexload-sdk/logger
2
-
3
- ## 1.0.1
4
-
5
- ### Patch Changes
6
-
7
- - c96fe18: publish access
8
-
9
- ## 1.0.0
10
-
11
- ### Major Changes
12
-
13
- - 8093666: initial first verison
14
-
15
- ### Patch Changes
16
-
17
- - Updated dependencies [8093666]
18
- - @nexload-sdk/env@1.0.0
@@ -1,5 +0,0 @@
1
- import { createBundler } from "@nexload-sdk/bundler";
2
-
3
- const esbuildBundler = createBundler();
4
-
5
- esbuildBundler();
package/eslint.config.mjs DELETED
@@ -1,4 +0,0 @@
1
- import { config } from "@nexload-sdk/eslint-config";
2
-
3
- /** @type {import("eslint").Linter.Config} */
4
- export default config;
package/src/index.ts DELETED
@@ -1,38 +0,0 @@
1
- import { EnvManager, merge } from "@nexload-sdk/env";
2
- import { $NodePreset } from "@nexload-sdk/env/presets";
3
- import pino from "pino";
4
- import pretty from "pino-pretty";
5
-
6
- const env = new EnvManager(
7
- "logger", merge($NodePreset)
8
- );
9
- const serviceName = env.$("SERVICE_NAME");
10
- const stream = pretty({
11
- colorize: pretty.isColorSupported,
12
- ignore: "pid,hostname",
13
- });
14
- const logger = pino(
15
- {
16
- name: serviceName,
17
- level: env.$("LOG_LEVEL"),
18
- timestamp: pino.stdTimeFunctions.isoTime,
19
- formatters: {
20
- level (label) {
21
- return { level: label.toUpperCase(), };
22
- },
23
- },
24
- base: { pid: process.pid, },
25
- redact: {
26
- paths: [
27
- "req.headers.authorization",
28
- "req.headers.cookie",
29
- "user.password",
30
- "user.secret"
31
- ],
32
- censor: "[REDACTED]",
33
- },
34
- }, stream
35
- );
36
-
37
- export { withLogger } from "./next-js";
38
- export default logger;
package/src/next-js.ts DELETED
@@ -1,105 +0,0 @@
1
- import logger from "./index";
2
-
3
- /**
4
- * Represents a value that may be a Promise or not.
5
- */
6
- type MaybePromise<T> = T | Promise<T>;
7
-
8
- /**
9
- * Operation type definitions
10
- */
11
- type LoggerRenderType = { type: "render" };
12
- type LoggerGetDataType = { type: "get-data", functionName?: string };
13
-
14
- export type LoggerOptions = { route: string } & (
15
- | LoggerRenderType
16
- | LoggerGetDataType
17
- );
18
- export type LoggerTimingShotFunction = (name: string) => void;
19
-
20
- const getLogOptions = (
21
- baseLog: Record<string, unknown>, duration: string
22
- ) => {
23
- if ("timing" in baseLog) {
24
- const timing = baseLog.timing as Record<string, number>;
25
-
26
- return {
27
- ...baseLog,
28
- timing: {
29
- ...Object.fromEntries(Object.entries(timing).map(([
30
- key,
31
- value
32
- ]) => [
33
- key,
34
- value.toFixed(2) + "ms"
35
- ])),
36
- total:
37
- Object.values(timing)
38
- .reduce(
39
- (
40
- acc, value
41
- ) => acc + value, 0
42
- )
43
- .toFixed(2) + "ms",
44
- },
45
- };
46
- }
47
-
48
- return { ...baseLog, duration, };
49
- };
50
-
51
- /**
52
- * Structured performance-aware logger wrapper.
53
- * Supports both sync and async functions (MaybePromise).
54
- */
55
- export async function withLogger<T> (
56
- options: LoggerOptions,
57
- fn: (timingShot: LoggerTimingShotFunction) => MaybePromise<T>
58
- ): Promise<T> {
59
- let start = performance.now();
60
- const operationName
61
- = options.type === "render" ? "Rendering" : "Getting data";
62
-
63
- const baseLog: Record<string, unknown> = {
64
- route: options.route,
65
- ...(options.type === "get-data" && options.functionName
66
- ? { functionName: options.functionName, }
67
- : {}),
68
- };
69
-
70
- logger.debug(
71
- baseLog, `${operationName} start`
72
- );
73
-
74
- const timingShot: LoggerTimingShotFunction = (name) => {
75
- const duration = performance.now() - start;
76
- start = performance.now();
77
-
78
- baseLog.timing ??= {};
79
- (baseLog.timing as Record<string, number>)[String(name)] = duration;
80
- };
81
-
82
- try {
83
- // Handle both sync and async results safely
84
- const result = await Promise.resolve(fn(timingShot));
85
- const duration = performance.now() - start;
86
-
87
- logger.debug(
88
- getLogOptions(
89
- baseLog, `${duration.toFixed(2)}ms`
90
- ), `${operationName} completed`
91
- );
92
-
93
- return result;
94
- } catch (error) {
95
- const duration = performance.now() - start;
96
-
97
- logger.error(
98
- getLogOptions(
99
- baseLog, `${duration.toFixed(2)}ms`
100
- ), `${operationName} failed`, error
101
- );
102
-
103
- throw error;
104
- }
105
- }
package/tsconfig.json DELETED
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "@nexload-sdk/typescript-config/base.json",
3
- "include": ["."],
4
- "compilerOptions": {
5
- "outDir": "./dist",
6
- "declaration": true,
7
- "emitDeclarationOnly": true
8
- },
9
- "exclude": ["node_modules", "dist"]
10
- }