opencode-logger 0.5.0 → 0.5.2

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.
@@ -21,6 +21,8 @@ export declare class FileLogger {
21
21
  private maxFileSize;
22
22
  private maxFiles;
23
23
  private pluginInput;
24
+ /** Mutex: each log() call chains onto this promise, serialising all writes. */
25
+ private _lock;
24
26
  /**
25
27
  * Creates a new instance of FileLogger.
26
28
  * @param projectRoot - The absolute path to the root of the project.
@@ -38,10 +40,16 @@ export declare class FileLogger {
38
40
  /**
39
41
  * Logs an event and its payload to the log file in JSONL format.
40
42
  * Automatically rotates the file if the configured maximum size has been reached.
43
+ *
44
+ * Concurrent calls are serialised via an async mutex so that the
45
+ * check-and-rotate step is never interleaved between two callers.
46
+ *
41
47
  * @param eventType - The type of event to log.
42
48
  * @param payload - The data associated with the event.
43
49
  */
44
50
  log(eventType: string, payload: unknown): Promise<void>;
51
+ /** Performs the actual write; always called serially through the mutex. */
52
+ private _doLog;
45
53
  /**
46
54
  * Checks whether the active log file has exceeded the maximum size and, if so, rotates it.
47
55
  * If maxFileSize is 0, rotation is disabled.
@@ -1 +1 @@
1
- {"version":3,"file":"file-logger.d.ts","sourceRoot":"","sources":["../src/file-logger.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAQvD;;GAEG;AACH,MAAM,WAAW,QAAQ;IACxB,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,uFAAuF;IACvF,SAAS,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,OAAO,EAAE,OAAO,CAAC;CACjB;AAED;;;GAGG;AACH,qBAAa,UAAU;IACtB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAA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;;;OAGG;YACW,cAAc;IAiB5B;;;OAGG;YACW,MAAM;IA+BpB;;OAEG;YACW,aAAa;CA+B3B"}
@@ -12,6 +12,8 @@ export class FileLogger {
12
12
  maxFileSize;
13
13
  maxFiles;
14
14
  pluginInput;
15
+ /** Mutex: each log() call chains onto this promise, serialising all writes. */
16
+ _lock = Promise.resolve();
15
17
  /**
16
18
  * Creates a new instance of FileLogger.
17
19
  * @param projectRoot - The absolute path to the root of the project.
@@ -58,10 +60,21 @@ export class FileLogger {
58
60
  /**
59
61
  * Logs an event and its payload to the log file in JSONL format.
60
62
  * Automatically rotates the file if the configured maximum size has been reached.
63
+ *
64
+ * Concurrent calls are serialised via an async mutex so that the
65
+ * check-and-rotate step is never interleaved between two callers.
66
+ *
61
67
  * @param eventType - The type of event to log.
62
68
  * @param payload - The data associated with the event.
63
69
  */
64
70
  async log(eventType, payload) {
71
+ // Chain this write onto the tail of the lock so all log() calls execute
72
+ // sequentially, regardless of how many are in-flight at once.
73
+ this._lock = this._lock.then(() => this._doLog(eventType, payload));
74
+ return this._lock;
75
+ }
76
+ /** Performs the actual write; always called serially through the mutex. */
77
+ async _doLog(eventType, payload) {
65
78
  const entry = {
66
79
  timestamp: new Date().toISOString(),
67
80
  eventType,
package/package.json CHANGED
@@ -2,7 +2,8 @@
2
2
  "name": "opencode-logger",
3
3
  "main": "dist/index.js",
4
4
  "types": "dist/index.d.ts",
5
- "version": "0.5.0",
5
+ "version": "0.5.2",
6
+ "license": "MIT",
6
7
  "repository": {
7
8
  "url": "git+https://github.com/radekBednarik/opencode-logger.git"
8
9
  },
@@ -22,7 +23,7 @@
22
23
  "@opencode-ai/plugin": "^1.2.10"
23
24
  },
24
25
  "devDependencies": {
25
- "@biomejs/biome": "2.3.11",
26
+ "@biomejs/biome": "2.4.4",
26
27
  "@types/bun": "latest",
27
28
  "husky": "^9.1.7",
28
29
  "lint-staged": "^16.2.7",