elysia-wide-event 0.1.2 → 0.1.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/README.md CHANGED
@@ -77,12 +77,13 @@ Add context to the current request log.
77
77
  wideEvent.set("auth", { userId: "123", role: "admin" });
78
78
  ```
79
79
 
80
- ### `wideEvent.error({ type, message })`
80
+ ### `wideEvent.error(data)`
81
81
 
82
- Log error details.
82
+ Log error details. Accepts any object.
83
83
 
84
84
  ```typescript
85
85
  wideEvent.error({ type: "ValidationError", message: "Invalid email" });
86
+ wideEvent.error({ code: "E001", reason: "timeout" });
86
87
  ```
87
88
 
88
89
  ## Requirements
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Elysia } from "elysia";
2
2
  import type { WideEventOptions, FlushableLogger } from "./types";
3
- export type { LogData, ErrorData, WideEventLogger, WideEventOptions, } from "./types";
3
+ export type { LogData, WideEventLogger, WideEventOptions } from "./types";
4
4
  export declare const wideEvent: (options?: WideEventOptions) => Elysia<"", {
5
5
  decorator: {};
6
6
  store: {};
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAGjE,YAAY,EACV,OAAO,EACP,SAAS,EACT,eAAe,EACf,gBAAgB,GACjB,MAAM,SAAS,CAAC;AAEjB,eAAO,MAAM,SAAS,GAAI,UAAS,gBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCvD,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAGjE,YAAY,EAAE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAE1E,eAAO,MAAM,SAAS,GAAI,UAAS,gBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCvD,CAAC;AAEF,eAAe,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -58,8 +58,7 @@ ${colors.dim}[${this.headerTime}]${colors.reset} ` + `${colors.yellow}${this.met
58
58
  console.log(` ${colors.blue}${key}:${colors.reset} ${formatData(data)}`);
59
59
  }
60
60
  if (this.errorData) {
61
- const errorMsg = this.errorData.message ? `${this.errorData.type}: ${this.errorData.message}` : this.errorData.type;
62
- console.log(` ${colors.red}\u2717${colors.reset} ${errorMsg}`);
61
+ console.log(` ${colors.red}error:${colors.reset} ${formatData(this.errorData)}`);
63
62
  }
64
63
  }
65
64
  flushJson(status, durationMs) {
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAIP,eAAe,EAChB,MAAM,SAAS,CAAC;AAkFjB,iBAAS,YAAY,CACnB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,GACf,eAAe,CAEjB;AAED,iBAAS,cAAc,CACrB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,OAAO,GACf,IAAI,CAqBN;AAED,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC"}
1
+ {"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EAGP,eAAe,EAChB,MAAM,SAAS,CAAC;AA+EjB,iBAAS,YAAY,CACnB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,OAAO,GACf,eAAe,CAEjB;AAED,iBAAS,cAAc,CACrB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,OAAO,EACjB,OAAO,EAAE,OAAO,GACf,IAAI,CAqBN;AAED,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,CAAC"}
package/dist/types.d.ts CHANGED
@@ -1,15 +1,9 @@
1
1
  export interface LogData {
2
2
  [key: string]: unknown;
3
3
  }
4
- export interface ErrorData {
5
- type: string;
6
- code?: string;
7
- message?: string;
8
- [key: string]: unknown;
9
- }
10
4
  export interface WideEventLogger {
11
5
  set: (key: string, data: LogData) => void;
12
- error: (error: ErrorData) => void;
6
+ error: (error: LogData) => void;
13
7
  }
14
8
  export interface WideEventOptions {
15
9
  /**
@@ -63,7 +57,7 @@ export interface WideEventRecord {
63
57
  path: string;
64
58
  status?: number;
65
59
  duration_ms?: number;
66
- error?: ErrorData;
60
+ error?: LogData;
67
61
  [key: string]: unknown;
68
62
  }
69
63
  export type FlushableLogger = WideEventLogger & {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,OAAO;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1C,KAAK,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;OASG;IACH,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W,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,MAAM,MAAM,eAAe,GAAG,eAAe,GAAG;IAC9C,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elysia-wide-event",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Wide event logging plugin for Elysia - structured logging with request context",
5
5
  "author": "Jay Choi",
6
6
  "license": "MIT",