coakka-logger-node 1.2.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/CONSUMING.md +35 -0
- package/LICENSE.md +115 -0
- package/README.md +45 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/logger.d.ts +35 -0
- package/dist/logger.js +121 -0
- package/dist/native-loader.d.ts +11 -0
- package/dist/native-loader.js +94 -0
- package/dist/native.d.ts +125 -0
- package/dist/native.js +363 -0
- package/dist/packaging.d.ts +4 -0
- package/dist/packaging.js +4 -0
- package/native/.gitkeep +1 -0
- package/native/linux-aarch64/libcoakka_logger_core-1.2.1+f50756ebff0d.so +0 -0
- package/native/linux-aarch64/libcoakka_logger_core.so +0 -0
- package/native/linux-x86_64/libcoakka_logger_core-1.2.1+f50756ebff0d.so +0 -0
- package/native/linux-x86_64/libcoakka_logger_core.so +0 -0
- package/native/macos-aarch64/libcoakka_logger_core-1.2.1+f50756ebff0d.dylib +0 -0
- package/native/macos-aarch64/libcoakka_logger_core.dylib +0 -0
- package/native/windows-aarch64/libcoakka_logger_core-1.2.1+f50756ebff0d.dll +0 -0
- package/native/windows-aarch64/libcoakka_logger_core.dll +0 -0
- package/native/windows-x86_64/libcoakka_logger_core-1.2.1+f50756ebff0d.dll +0 -0
- package/native/windows-x86_64/libcoakka_logger_core.dll +0 -0
- package/package.json +31 -0
- package/vendor/koffi/LICENSE.txt +22 -0
- package/vendor/koffi/build/koffi/darwin_arm64/koffi.node +0 -0
- package/vendor/koffi/build/koffi/darwin_x64/koffi.node +0 -0
- package/vendor/koffi/build/koffi/freebsd_arm64/koffi.node +0 -0
- package/vendor/koffi/build/koffi/freebsd_ia32/koffi.node +0 -0
- package/vendor/koffi/build/koffi/freebsd_x64/koffi.node +0 -0
- package/vendor/koffi/build/koffi/linux_arm64/koffi.node +0 -0
- package/vendor/koffi/build/koffi/linux_armhf/koffi.node +0 -0
- package/vendor/koffi/build/koffi/linux_ia32/koffi.node +0 -0
- package/vendor/koffi/build/koffi/linux_loong64/koffi.node +0 -0
- package/vendor/koffi/build/koffi/linux_riscv64d/koffi.node +0 -0
- package/vendor/koffi/build/koffi/linux_x64/koffi.node +0 -0
- package/vendor/koffi/build/koffi/musl_arm64/koffi.node +0 -0
- package/vendor/koffi/build/koffi/musl_x64/koffi.node +0 -0
- package/vendor/koffi/build/koffi/openbsd_ia32/koffi.node +0 -0
- package/vendor/koffi/build/koffi/openbsd_x64/koffi.node +0 -0
- package/vendor/koffi/build/koffi/win32_arm64/koffi.exp +0 -0
- package/vendor/koffi/build/koffi/win32_arm64/koffi.lib +0 -0
- package/vendor/koffi/build/koffi/win32_arm64/koffi.node +0 -0
- package/vendor/koffi/build/koffi/win32_ia32/koffi.exp +0 -0
- package/vendor/koffi/build/koffi/win32_ia32/koffi.lib +0 -0
- package/vendor/koffi/build/koffi/win32_ia32/koffi.node +0 -0
- package/vendor/koffi/build/koffi/win32_x64/koffi.exp +0 -0
- package/vendor/koffi/build/koffi/win32_x64/koffi.lib +0 -0
- package/vendor/koffi/build/koffi/win32_x64/koffi.node +0 -0
- package/vendor/koffi/index.d.ts +288 -0
- package/vendor/koffi/index.js +634 -0
- package/vendor/koffi/package.json +38 -0
package/CONSUMING.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Consuming `coakka-logger-node`
|
|
2
|
+
|
|
3
|
+
The Node.js logger package is a binary tarball that embeds the native logger
|
|
4
|
+
core. Applications normally do not need to pass a native library path.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { CoakkaLoggerLevel, Logger } from "coakka-logger-node";
|
|
8
|
+
|
|
9
|
+
const logger = Logger.start({ minLevel: CoakkaLoggerLevel.INFO });
|
|
10
|
+
try {
|
|
11
|
+
logger.info("orders", "accepted");
|
|
12
|
+
const record = logger.awaitNext(1000);
|
|
13
|
+
} finally {
|
|
14
|
+
logger.close();
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
For local development or diagnostics, an explicit native library path can be
|
|
19
|
+
provided:
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
Logger.start({}, "/abs/path/to/libcoakka_logger_core.dylib");
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The environment override is:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
COAKKA_LOGGER_LIB=/abs/path/to/libcoakka_logger_core.so
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Current embedded native package:
|
|
32
|
+
|
|
33
|
+
- native core version: `1.2.1`
|
|
34
|
+
- native package version: `1.2.1+f50756ebff0d`
|
|
35
|
+
- platforms: `macos-aarch64`, `linux-aarch64`, `linux-x86_64`
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# CoAkka Public Artifact Preview License 1.0
|
|
2
|
+
|
|
3
|
+
Effective: 2026-07-19
|
|
4
|
+
|
|
5
|
+
This repository is the public binary artifact surface for CoAkka. It contains
|
|
6
|
+
headers, native libraries, connector packages, Maven artifacts, checksums, and
|
|
7
|
+
artifact metadata. It is not a source-build repository.
|
|
8
|
+
|
|
9
|
+
Unless a specific release artifact includes different license terms, the
|
|
10
|
+
artifacts in this repository are made available under the following preview
|
|
11
|
+
terms.
|
|
12
|
+
|
|
13
|
+
This is not an OSI-approved open source license. The separate
|
|
14
|
+
`coakka-samples` repository may use a permissive open source license for sample
|
|
15
|
+
code and documentation; that sample license does not change the terms for the
|
|
16
|
+
artifacts distributed from this repository.
|
|
17
|
+
|
|
18
|
+
## Definitions
|
|
19
|
+
|
|
20
|
+
`Artifacts` means the CoAkka binaries, headers, libraries, connector packages,
|
|
21
|
+
Maven artifacts, container-bundle files, checksums, manifests, and release
|
|
22
|
+
metadata distributed from this repository or from an official release page for
|
|
23
|
+
this repository.
|
|
24
|
+
|
|
25
|
+
`Production` means any environment that serves live end-user traffic, live
|
|
26
|
+
customer data, live operational data, revenue-generating workloads, or
|
|
27
|
+
customer-facing workloads outside development, test, CI, sample execution, or
|
|
28
|
+
proof-of-concept evaluation.
|
|
29
|
+
|
|
30
|
+
`Official sample images` means container images published by the CoAkka
|
|
31
|
+
project or repository owner, including the current
|
|
32
|
+
`docker.io/gabrielgun1983/*` sample image namespace and any future images
|
|
33
|
+
published under an official CoAkka container namespace, that bundle unmodified
|
|
34
|
+
artifacts solely to run official CoAkka samples.
|
|
35
|
+
|
|
36
|
+
## Allowed Use
|
|
37
|
+
|
|
38
|
+
You may download, copy, and use the artifacts from this repository to:
|
|
39
|
+
|
|
40
|
+
- evaluate CoAkka locally
|
|
41
|
+
- run the official public samples
|
|
42
|
+
- build proof-of-concept integrations
|
|
43
|
+
- run development and test environments for applications that integrate with
|
|
44
|
+
CoAkka
|
|
45
|
+
- run CI jobs, automated tests, and integration verification for
|
|
46
|
+
non-production applications or evaluations
|
|
47
|
+
- run company evaluations, proofs of concept, and integration tests,
|
|
48
|
+
including evaluations inside commercial organizations
|
|
49
|
+
- redistribute unmodified CoAkka artifacts inside local development, test, or
|
|
50
|
+
sample environments, provided this notice and the included checksums or
|
|
51
|
+
manifests remain available
|
|
52
|
+
- pull, cache internally, and run official sample images for local development,
|
|
53
|
+
CI, test, sample execution, proof-of-concept integration, and evaluation
|
|
54
|
+
|
|
55
|
+
## Reserved Uses
|
|
56
|
+
|
|
57
|
+
The following uses require a separate written license:
|
|
58
|
+
|
|
59
|
+
- selling, hosting, or offering CoAkka artifacts as a managed runtime service
|
|
60
|
+
- running CoAkka artifacts in production systems
|
|
61
|
+
- bundling CoAkka artifacts into a product distributed to customers
|
|
62
|
+
- redistributing CoAkka artifacts as part of a paid product, support package,
|
|
63
|
+
appliance, cloud image, or hosted service
|
|
64
|
+
- offering a product or service that presents modified CoAkka artifacts as
|
|
65
|
+
official CoAkka artifacts
|
|
66
|
+
- removing or obscuring copyright, license, checksum, or provenance notices
|
|
67
|
+
- reverse engineering artifacts except where that restriction is prohibited by
|
|
68
|
+
applicable law
|
|
69
|
+
- using the CoAkka name, package names, artifact names, image names, or other
|
|
70
|
+
project identifiers in a way that implies endorsement of an unofficial fork,
|
|
71
|
+
hosted service, or product
|
|
72
|
+
|
|
73
|
+
## Official Samples
|
|
74
|
+
|
|
75
|
+
Official sample images may bundle unmodified artifacts solely so users can run
|
|
76
|
+
official CoAkka samples without installing the artifacts manually.
|
|
77
|
+
|
|
78
|
+
This sample-image permission does not grant third parties the right to create,
|
|
79
|
+
publish, sell, host, or distribute derivative images for production, customer
|
|
80
|
+
distribution, hosted services, paid support packages, appliances, or cloud
|
|
81
|
+
marketplace offerings.
|
|
82
|
+
|
|
83
|
+
## Production Use
|
|
84
|
+
|
|
85
|
+
These preview terms are intended for developer evaluation, sample execution,
|
|
86
|
+
non-production proof-of-concept work, CI, and integration testing. Production
|
|
87
|
+
use, hosted service use, customer distribution, and paid redistribution require
|
|
88
|
+
explicit release terms or a separate written agreement.
|
|
89
|
+
|
|
90
|
+
For production, hosted service, customer distribution, paid redistribution, or
|
|
91
|
+
other commercial rights, contact the project through `SUPPORT.md`.
|
|
92
|
+
|
|
93
|
+
## No Warranty
|
|
94
|
+
|
|
95
|
+
The artifacts are provided as-is, without warranties or conditions of any kind,
|
|
96
|
+
to the maximum extent permitted by applicable law.
|
|
97
|
+
|
|
98
|
+
## Limitation Of Liability
|
|
99
|
+
|
|
100
|
+
To the maximum extent permitted by applicable law, the project contributors and
|
|
101
|
+
artifact publishers are not liable for any direct, indirect, incidental,
|
|
102
|
+
special, consequential, exemplary, or other damages arising from use of the
|
|
103
|
+
artifacts.
|
|
104
|
+
|
|
105
|
+
## No Patent Or Trademark Grant
|
|
106
|
+
|
|
107
|
+
These preview terms do not grant patent rights, trademark rights, or rights to
|
|
108
|
+
use the CoAkka name beyond the limited artifact and sample uses allowed above.
|
|
109
|
+
Trademark use is governed by `TRADEMARKS.md`.
|
|
110
|
+
|
|
111
|
+
## Legal Notice
|
|
112
|
+
|
|
113
|
+
This file is not legal advice. If your intended use depends on legal
|
|
114
|
+
interpretation of these terms, consult your own counsel or request a separate
|
|
115
|
+
written agreement.
|
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# CoAkka Logger Node
|
|
2
|
+
|
|
3
|
+
`logger/node/` is the Node.js host connector lane for the standalone CoAkka
|
|
4
|
+
native logger core.
|
|
5
|
+
|
|
6
|
+
It mirrors the Python logger lane:
|
|
7
|
+
|
|
8
|
+
- load `libcoakka_logger_core` through `koffi`
|
|
9
|
+
- keep Node-side formatting above the native core
|
|
10
|
+
- let the native logger own queueing, pressure policy, sinks, and lifecycle
|
|
11
|
+
- package staged native libraries into the npm tarball for macOS aarch64,
|
|
12
|
+
Linux aarch64, and Linux x86_64
|
|
13
|
+
|
|
14
|
+
## Build
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npm --prefix logger/node run build
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
The script stages native libraries from:
|
|
21
|
+
|
|
22
|
+
```text
|
|
23
|
+
logger/staging/native/1.2.1+f50756ebff0d/
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Smoke
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
npm --prefix logger/node test
|
|
30
|
+
npm --prefix logger/node run smoke:packaged
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Example
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { Logger } from "coakka-logger-node";
|
|
37
|
+
|
|
38
|
+
const logger = Logger.start();
|
|
39
|
+
try {
|
|
40
|
+
logger.info("app", "started");
|
|
41
|
+
const record = logger.awaitNext(1000);
|
|
42
|
+
} finally {
|
|
43
|
+
logger.close();
|
|
44
|
+
}
|
|
45
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { LOGGER_NATIVE_CORE_VERSION, LOGGER_NATIVE_GIT_COMMIT, LOGGER_NATIVE_PACKAGE_VERSION, LOGGER_NODE_VERSION, } from "./packaging.js";
|
|
2
|
+
export { Logger, type LoggerSpec, } from "./logger.js";
|
|
3
|
+
export { COAKKA_LOGGER_CORE_ABI_VERSION, CoakkaLoggerLevel, CoakkaLoggerLevelMask, CoakkaLoggerPressureState, CoakkaLoggerSinkMode, CoakkaLoggerSinkTarget, CoakkaLoggerStatus, LoggerStatusError, type LoggerConfigSnapshot, type LoggerInfoSnapshot, type LoggerRecordSnapshot, type LoggerStatsSnapshot, } from "./native.js";
|
|
4
|
+
export { LoggerLibraryResolver, } from "./native-loader.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { LOGGER_NATIVE_CORE_VERSION, LOGGER_NATIVE_GIT_COMMIT, LOGGER_NATIVE_PACKAGE_VERSION, LOGGER_NODE_VERSION, } from "./packaging.js";
|
|
2
|
+
export { Logger, } from "./logger.js";
|
|
3
|
+
export { COAKKA_LOGGER_CORE_ABI_VERSION, CoakkaLoggerLevel, CoakkaLoggerLevelMask, CoakkaLoggerPressureState, CoakkaLoggerSinkMode, CoakkaLoggerSinkTarget, CoakkaLoggerStatus, LoggerStatusError, } from "./native.js";
|
|
4
|
+
export { LoggerLibraryResolver, } from "./native-loader.js";
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type LoggerConfigSnapshot, type LoggerInfoSnapshot, type LoggerRecordSnapshot, type LoggerStatsSnapshot } from "./native.js";
|
|
2
|
+
export interface LoggerSpec {
|
|
3
|
+
systemName?: string;
|
|
4
|
+
queueCapacity?: number;
|
|
5
|
+
categoryCapacity?: number;
|
|
6
|
+
messageCapacity?: number;
|
|
7
|
+
minLevel?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare class Logger {
|
|
10
|
+
private readonly bindings;
|
|
11
|
+
private readonly handle;
|
|
12
|
+
private readonly spec;
|
|
13
|
+
static start(spec?: LoggerSpec, loggerLibPath?: string): Logger;
|
|
14
|
+
static readInfo(loggerLibPath?: string): LoggerInfoSnapshot;
|
|
15
|
+
private stopped;
|
|
16
|
+
private closed;
|
|
17
|
+
private constructor();
|
|
18
|
+
config(): LoggerConfigSnapshot;
|
|
19
|
+
stats(): LoggerStatsSnapshot;
|
|
20
|
+
isEnabled(level: number): boolean;
|
|
21
|
+
isEnabledForCategory(category: string, level: number): boolean;
|
|
22
|
+
log(level: number, category: string, message: string): number | null;
|
|
23
|
+
trace(category: string, message: string): number | null;
|
|
24
|
+
debug(category: string, message: string): number | null;
|
|
25
|
+
info(category: string, message: string): number | null;
|
|
26
|
+
warn(category: string, message: string): number | null;
|
|
27
|
+
error(category: string, message: string): number | null;
|
|
28
|
+
fatal(category: string, message: string): number | null;
|
|
29
|
+
poll(): LoggerRecordSnapshot | null;
|
|
30
|
+
awaitNext(timeoutMs?: number): LoggerRecordSnapshot | null;
|
|
31
|
+
stop(): void;
|
|
32
|
+
close(): void;
|
|
33
|
+
[Symbol.dispose](): void;
|
|
34
|
+
private requireOpen;
|
|
35
|
+
}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { COAKKA_LOGGER_CORE_ABI_VERSION, CoakkaLoggerLevel, NativeLoggerBindings, } from "./native.js";
|
|
2
|
+
import { LoggerLibraryResolver } from "./native-loader.js";
|
|
3
|
+
export class Logger {
|
|
4
|
+
bindings;
|
|
5
|
+
handle;
|
|
6
|
+
spec;
|
|
7
|
+
static start(spec = {}, loggerLibPath) {
|
|
8
|
+
const resolvedSpec = resolveSpec(spec);
|
|
9
|
+
const bindings = new NativeLoggerBindings(LoggerLibraryResolver.resolve(loggerLibPath));
|
|
10
|
+
const abiVersion = bindings.getAbiVersion();
|
|
11
|
+
if (abiVersion !== COAKKA_LOGGER_CORE_ABI_VERSION) {
|
|
12
|
+
throw new Error(`unexpected logger ABI version: expected ${COAKKA_LOGGER_CORE_ABI_VERSION}, got ${abiVersion}`);
|
|
13
|
+
}
|
|
14
|
+
const handle = bindings.create(resolvedSpec);
|
|
15
|
+
try {
|
|
16
|
+
bindings.start(handle);
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
bindings.destroy(handle);
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
return new Logger(bindings, handle, resolvedSpec);
|
|
23
|
+
}
|
|
24
|
+
static readInfo(loggerLibPath) {
|
|
25
|
+
return new NativeLoggerBindings(LoggerLibraryResolver.resolve(loggerLibPath)).readInfo();
|
|
26
|
+
}
|
|
27
|
+
stopped = false;
|
|
28
|
+
closed = false;
|
|
29
|
+
constructor(bindings, handle, spec) {
|
|
30
|
+
this.bindings = bindings;
|
|
31
|
+
this.handle = handle;
|
|
32
|
+
this.spec = spec;
|
|
33
|
+
}
|
|
34
|
+
config() {
|
|
35
|
+
this.requireOpen();
|
|
36
|
+
return this.bindings.config(this.handle);
|
|
37
|
+
}
|
|
38
|
+
stats() {
|
|
39
|
+
this.requireOpen();
|
|
40
|
+
return this.bindings.stats(this.handle);
|
|
41
|
+
}
|
|
42
|
+
isEnabled(level) {
|
|
43
|
+
this.requireOpen();
|
|
44
|
+
return this.bindings.isEnabled(this.handle, level);
|
|
45
|
+
}
|
|
46
|
+
isEnabledForCategory(category, level) {
|
|
47
|
+
this.requireOpen();
|
|
48
|
+
return this.bindings.isEnabledForCategory(this.handle, category, level);
|
|
49
|
+
}
|
|
50
|
+
log(level, category, message) {
|
|
51
|
+
if (!this.isEnabledForCategory(category, level)) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
this.requireOpen();
|
|
55
|
+
return this.bindings.log(this.handle, level, category, message);
|
|
56
|
+
}
|
|
57
|
+
trace(category, message) {
|
|
58
|
+
return this.log(CoakkaLoggerLevel.TRACE, category, message);
|
|
59
|
+
}
|
|
60
|
+
debug(category, message) {
|
|
61
|
+
return this.log(CoakkaLoggerLevel.DEBUG, category, message);
|
|
62
|
+
}
|
|
63
|
+
info(category, message) {
|
|
64
|
+
return this.log(CoakkaLoggerLevel.INFO, category, message);
|
|
65
|
+
}
|
|
66
|
+
warn(category, message) {
|
|
67
|
+
return this.log(CoakkaLoggerLevel.WARN, category, message);
|
|
68
|
+
}
|
|
69
|
+
error(category, message) {
|
|
70
|
+
return this.log(CoakkaLoggerLevel.ERROR, category, message);
|
|
71
|
+
}
|
|
72
|
+
fatal(category, message) {
|
|
73
|
+
return this.log(CoakkaLoggerLevel.FATAL, category, message);
|
|
74
|
+
}
|
|
75
|
+
poll() {
|
|
76
|
+
return this.awaitNext(0);
|
|
77
|
+
}
|
|
78
|
+
awaitNext(timeoutMs = 1000) {
|
|
79
|
+
this.requireOpen();
|
|
80
|
+
return this.bindings.readNext(this.handle, timeoutMs, this.spec.categoryCapacity, this.spec.messageCapacity);
|
|
81
|
+
}
|
|
82
|
+
stop() {
|
|
83
|
+
if (this.closed || this.stopped) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this.bindings.stop(this.handle);
|
|
87
|
+
this.stopped = true;
|
|
88
|
+
}
|
|
89
|
+
close() {
|
|
90
|
+
if (this.closed) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (!this.stopped) {
|
|
94
|
+
try {
|
|
95
|
+
this.bindings.stop(this.handle);
|
|
96
|
+
}
|
|
97
|
+
finally {
|
|
98
|
+
this.stopped = true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
this.bindings.destroy(this.handle);
|
|
102
|
+
this.closed = true;
|
|
103
|
+
}
|
|
104
|
+
[Symbol.dispose]() {
|
|
105
|
+
this.close();
|
|
106
|
+
}
|
|
107
|
+
requireOpen() {
|
|
108
|
+
if (this.closed) {
|
|
109
|
+
throw new Error("logger is closed");
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function resolveSpec(spec) {
|
|
114
|
+
return {
|
|
115
|
+
systemName: spec.systemName ?? "nodeLogger",
|
|
116
|
+
queueCapacity: spec.queueCapacity ?? 256,
|
|
117
|
+
categoryCapacity: spec.categoryCapacity ?? 64,
|
|
118
|
+
messageCapacity: spec.messageCapacity ?? 512,
|
|
119
|
+
minLevel: spec.minLevel ?? CoakkaLoggerLevel.TRACE,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class LoggerLibraryResolver {
|
|
2
|
+
static readonly envVar = "COAKKA_LOGGER_LIB";
|
|
3
|
+
static resolve(explicitPath?: string): string;
|
|
4
|
+
static platformId(osName?: NodeJS.Platform, archName?: NodeJS.Architecture): string;
|
|
5
|
+
static normalizeOs(osName: string): string;
|
|
6
|
+
static normalizeArch(archName: string): string;
|
|
7
|
+
static resourceFileNamesForCurrentPlatform(osName?: NodeJS.Platform): string[];
|
|
8
|
+
private static resolveEmbedded;
|
|
9
|
+
private static searchCandidates;
|
|
10
|
+
private static requireExisting;
|
|
11
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { tmpdir } from "node:os";
|
|
3
|
+
import { dirname, resolve } from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { LOGGER_NATIVE_PACKAGE_VERSION } from "./packaging.js";
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
export class LoggerLibraryResolver {
|
|
8
|
+
static envVar = "COAKKA_LOGGER_LIB";
|
|
9
|
+
static resolve(explicitPath) {
|
|
10
|
+
if (explicitPath != null && explicitPath.trim() !== "") {
|
|
11
|
+
return this.requireExisting(resolve(explicitPath), "explicit loggerLibPath");
|
|
12
|
+
}
|
|
13
|
+
const configuredPath = process.env[this.envVar]?.trim();
|
|
14
|
+
if (configuredPath != null && configuredPath !== "") {
|
|
15
|
+
return this.requireExisting(resolve(configuredPath), `$${this.envVar}`);
|
|
16
|
+
}
|
|
17
|
+
const embedded = this.resolveEmbedded();
|
|
18
|
+
if (embedded != null) {
|
|
19
|
+
return embedded;
|
|
20
|
+
}
|
|
21
|
+
for (const candidate of this.searchCandidates()) {
|
|
22
|
+
if (existsSync(candidate)) {
|
|
23
|
+
return candidate;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
throw new Error("native logger library was not found. " +
|
|
27
|
+
`Set ${this.envVar}, pass loggerLibPath explicitly, or package one of ` +
|
|
28
|
+
`${this.resourceFileNamesForCurrentPlatform().join(", ")} under logger/node/native/${this.platformId()}/.`);
|
|
29
|
+
}
|
|
30
|
+
static platformId(osName = process.platform, archName = process.arch) {
|
|
31
|
+
return `${this.normalizeOs(osName)}-${this.normalizeArch(archName)}`;
|
|
32
|
+
}
|
|
33
|
+
static normalizeOs(osName) {
|
|
34
|
+
const normalized = osName.toLowerCase();
|
|
35
|
+
if (normalized === "darwin" || normalized.includes("mac")) {
|
|
36
|
+
return "macos";
|
|
37
|
+
}
|
|
38
|
+
if (normalized === "linux" || normalized.includes("linux")) {
|
|
39
|
+
return "linux";
|
|
40
|
+
}
|
|
41
|
+
if (normalized === "win32" || normalized.includes("windows")) {
|
|
42
|
+
return "windows";
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`unsupported os.name=${osName}; supported platforms are macOS, Linux, and Windows`);
|
|
45
|
+
}
|
|
46
|
+
static normalizeArch(archName) {
|
|
47
|
+
const normalized = archName.toLowerCase();
|
|
48
|
+
if (normalized === "arm64" || normalized === "aarch64") {
|
|
49
|
+
return "aarch64";
|
|
50
|
+
}
|
|
51
|
+
if (normalized === "x64" || normalized === "x86_64" || normalized === "amd64") {
|
|
52
|
+
return "x86_64";
|
|
53
|
+
}
|
|
54
|
+
throw new Error(`unsupported os.arch=${archName}; supported architectures are aarch64 and x86_64`);
|
|
55
|
+
}
|
|
56
|
+
static resourceFileNamesForCurrentPlatform(osName = process.platform) {
|
|
57
|
+
const versionedBase = `libcoakka_logger_core-${LOGGER_NATIVE_PACKAGE_VERSION}`;
|
|
58
|
+
switch (this.normalizeOs(osName)) {
|
|
59
|
+
case "macos":
|
|
60
|
+
return [`${versionedBase}.dylib`, "libcoakka_logger_core.dylib", "libcoakka_logger_core.so"];
|
|
61
|
+
case "linux":
|
|
62
|
+
return [`${versionedBase}.so`, "libcoakka_logger_core.so"];
|
|
63
|
+
case "windows":
|
|
64
|
+
return [`${versionedBase}.dll`, "libcoakka_logger_core.dll"];
|
|
65
|
+
default:
|
|
66
|
+
throw new Error("unsupported platform");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
static resolveEmbedded() {
|
|
70
|
+
const platformId = this.platformId();
|
|
71
|
+
for (const fileName of this.resourceFileNamesForCurrentPlatform()) {
|
|
72
|
+
const resourcePath = resolve(__dirname, "..", "native", platformId, fileName);
|
|
73
|
+
if (existsSync(resourcePath)) {
|
|
74
|
+
const tempDir = mkdtempSync(resolve(tmpdir(), "coakka-logger-node-"));
|
|
75
|
+
process.once("exit", () => rmSync(tempDir, { recursive: true, force: true }));
|
|
76
|
+
const targetPath = resolve(tempDir, fileName);
|
|
77
|
+
writeFileSync(targetPath, readFileSync(resourcePath));
|
|
78
|
+
return targetPath;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
static searchCandidates() {
|
|
84
|
+
const cwd = process.cwd();
|
|
85
|
+
const roots = [resolve(cwd, "lib"), resolve(cwd, "logger", "node", "lib")];
|
|
86
|
+
return roots.flatMap((root) => this.resourceFileNamesForCurrentPlatform().map((name) => resolve(root, name)));
|
|
87
|
+
}
|
|
88
|
+
static requireExisting(path, source) {
|
|
89
|
+
if (!existsSync(path)) {
|
|
90
|
+
throw new Error(`${source} does not exist: ${path}`);
|
|
91
|
+
}
|
|
92
|
+
return path;
|
|
93
|
+
}
|
|
94
|
+
}
|
package/dist/native.d.ts
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export declare const COAKKA_LOGGER_CORE_ABI_VERSION = 10;
|
|
2
|
+
export declare const CoakkaLoggerStatus: {
|
|
3
|
+
readonly OK: 0;
|
|
4
|
+
readonly INVALID_ARGUMENT: 1;
|
|
5
|
+
readonly BAD_STATE: 2;
|
|
6
|
+
readonly QUEUE_FULL: 3;
|
|
7
|
+
readonly RECORD_TOO_LARGE: 4;
|
|
8
|
+
readonly TIMED_OUT: 5;
|
|
9
|
+
readonly BUFFER_TOO_SMALL: 6;
|
|
10
|
+
readonly INTERNAL_ERROR: 7;
|
|
11
|
+
};
|
|
12
|
+
export declare const CoakkaLoggerLevel: {
|
|
13
|
+
readonly TRACE: 0;
|
|
14
|
+
readonly DEBUG: 1;
|
|
15
|
+
readonly INFO: 2;
|
|
16
|
+
readonly WARN: 3;
|
|
17
|
+
readonly ERROR: 4;
|
|
18
|
+
readonly FATAL: 5;
|
|
19
|
+
};
|
|
20
|
+
export declare const CoakkaLoggerSinkMode: {
|
|
21
|
+
readonly MANUAL_DRAIN: 0;
|
|
22
|
+
readonly FILE: 1;
|
|
23
|
+
readonly CONSOLE: 2;
|
|
24
|
+
readonly MULTI: 3;
|
|
25
|
+
};
|
|
26
|
+
export declare const CoakkaLoggerSinkTarget: {
|
|
27
|
+
readonly NONE: 0;
|
|
28
|
+
readonly FILE: number;
|
|
29
|
+
readonly CONSOLE: number;
|
|
30
|
+
};
|
|
31
|
+
export declare const CoakkaLoggerPressureState: {
|
|
32
|
+
readonly NORMAL: 0;
|
|
33
|
+
readonly QUOTA_PRESSURE: 1;
|
|
34
|
+
readonly DROP_LOW_PRIORITY: 2;
|
|
35
|
+
readonly EMERGENCY_ONLY: 3;
|
|
36
|
+
};
|
|
37
|
+
export declare const CoakkaLoggerLevelMask: {
|
|
38
|
+
readonly TRACE: number;
|
|
39
|
+
readonly DEBUG: number;
|
|
40
|
+
readonly INFO: number;
|
|
41
|
+
readonly WARN: number;
|
|
42
|
+
readonly ERROR: number;
|
|
43
|
+
readonly FATAL: number;
|
|
44
|
+
readonly ALL: number;
|
|
45
|
+
};
|
|
46
|
+
export interface LoggerInfoSnapshot {
|
|
47
|
+
abiVersion: number;
|
|
48
|
+
runtimeVersion: string;
|
|
49
|
+
gitCommit: string;
|
|
50
|
+
docsHint: string;
|
|
51
|
+
}
|
|
52
|
+
export interface LoggerConfigSnapshot {
|
|
53
|
+
systemName: string;
|
|
54
|
+
state: number;
|
|
55
|
+
stateName: string;
|
|
56
|
+
queueCapacity: number;
|
|
57
|
+
categoryCapacity: number;
|
|
58
|
+
messageCapacity: number;
|
|
59
|
+
}
|
|
60
|
+
export interface LoggerStatsSnapshot {
|
|
61
|
+
state: number;
|
|
62
|
+
stateName: string;
|
|
63
|
+
queueCapacity: number;
|
|
64
|
+
queueDepth: number;
|
|
65
|
+
queueHighWatermark: number;
|
|
66
|
+
nextSequence: number;
|
|
67
|
+
emittedCount: number;
|
|
68
|
+
deliveredCount: number;
|
|
69
|
+
droppedCount: number;
|
|
70
|
+
}
|
|
71
|
+
export interface LoggerRecordSnapshot {
|
|
72
|
+
sequence: number;
|
|
73
|
+
wallTimeUnixMs: number;
|
|
74
|
+
monotonicTimeNs: number;
|
|
75
|
+
level: number;
|
|
76
|
+
levelName: string;
|
|
77
|
+
category: string;
|
|
78
|
+
message: string;
|
|
79
|
+
}
|
|
80
|
+
export interface NativeLoggerConfig {
|
|
81
|
+
systemName: string;
|
|
82
|
+
queueCapacity: number;
|
|
83
|
+
categoryCapacity: number;
|
|
84
|
+
messageCapacity: number;
|
|
85
|
+
minLevel: number;
|
|
86
|
+
}
|
|
87
|
+
export declare class LoggerStatusError extends Error {
|
|
88
|
+
readonly operation: string;
|
|
89
|
+
readonly status: number;
|
|
90
|
+
readonly statusName: string;
|
|
91
|
+
constructor(operation: string, status: number, statusName: string);
|
|
92
|
+
}
|
|
93
|
+
export declare class NativeLoggerBindings {
|
|
94
|
+
readonly loggerLibPath: string;
|
|
95
|
+
private readonly lib;
|
|
96
|
+
private readonly getAbiVersionFn;
|
|
97
|
+
private readonly getInfoFn;
|
|
98
|
+
private readonly createFn;
|
|
99
|
+
private readonly startFn;
|
|
100
|
+
private readonly stopFn;
|
|
101
|
+
private readonly destroyFn;
|
|
102
|
+
private readonly getConfigFn;
|
|
103
|
+
private readonly getStatsFn;
|
|
104
|
+
private readonly isEnabledFn;
|
|
105
|
+
private readonly isEnabledForCategoryFn;
|
|
106
|
+
private readonly logFn;
|
|
107
|
+
private readonly readNextFn;
|
|
108
|
+
private readonly statusNameFn;
|
|
109
|
+
private readonly levelNameFn;
|
|
110
|
+
private readonly stateNameFn;
|
|
111
|
+
constructor(loggerLibPath: string);
|
|
112
|
+
getAbiVersion(): number;
|
|
113
|
+
readInfo(): LoggerInfoSnapshot;
|
|
114
|
+
create(config: NativeLoggerConfig): unknown;
|
|
115
|
+
start(handle: unknown): void;
|
|
116
|
+
stop(handle: unknown): void;
|
|
117
|
+
destroy(handle: unknown): void;
|
|
118
|
+
config(handle: unknown): LoggerConfigSnapshot;
|
|
119
|
+
stats(handle: unknown): LoggerStatsSnapshot;
|
|
120
|
+
isEnabled(handle: unknown, level: number): boolean;
|
|
121
|
+
isEnabledForCategory(handle: unknown, category: string, level: number): boolean;
|
|
122
|
+
log(handle: unknown, level: number, category: string, message: string): number;
|
|
123
|
+
readNext(handle: unknown, timeoutMs: number, categoryCapacity: number, messageCapacity: number): LoggerRecordSnapshot | null;
|
|
124
|
+
requireOk(status: number, operation: string): void;
|
|
125
|
+
}
|