-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmod.ts
More file actions
90 lines (76 loc) 路 2.9 KB
/
Copy pathmod.ts
File metadata and controls
90 lines (76 loc) 路 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// Copyright 2023-present Eser Ozvataf and other contributors. All rights reserved. Apache-2.0 license.
/**
* @module @eserstack/logging
*
* A hierarchical, category-based logging system with context propagation,
* multiple sinks, filters, and OpenTelemetry integration.
*
* @example Basic Usage
* ```typescript
* import * as logging from "@eserstack/logging";
* import * as streams from "@eserstack/streams";
*
* // Create an Output with a renderer and sink
* const out = streams.output({ renderer: streams.renderers.ansi(), sink: streams.sinks.stdout() });
*
* // Configure once at app startup
* await logging.config.configure({
* sinks: {
* console: logging.sinks.getOutputSink(out),
* },
* loggers: [
* { category: ["myapp"], lowestLevel: logging.Severities.Debug, sinks: ["console"] },
* ],
* });
*
* // Get a logger by category
* const logger = logging.logger.getLogger(["myapp", "http"]);
* await logger.info("Request received");
* ```
*
* @example Context Propagation
* ```typescript
* import * as logging from "@eserstack/logging";
*
* await logging.context.withContext({ requestId: "abc-123" }, async () => {
* const logger = logging.logger.getLogger(["myapp"]);
* await logger.info("Processing request"); // Includes requestId automatically
* });
* ```
*/
// ============================================================================
// NAMESPACE EXPORTS (primary API)
// ============================================================================
/** Type definitions and utilities */
export * as types from "./types.ts";
/** Category utilities for hierarchical logger organization */
export * as category from "./category.ts";
/** Configuration system - configure(), reset() */
export * as config from "./config.ts";
/** Logger class and utilities - Logger, getLogger(), DEFAULT_LEVEL */
export * as logger from "./logger.ts";
/** Context propagation - withContext(), getContext() */
export * as context from "./context.ts";
/** Sink implementations - console, stream, buffered, etc. */
export * as sinks from "./sinks.ts";
/** Filter utilities - level, category, rate limit, sampling */
export * as filters from "./filters.ts";
/** Formatter functions - JSON, text, span-based */
export * as formatters from "./formatters.ts";
/** OpenTelemetry integration - withSpan(), tracer */
export * as tracer from "./tracer.ts";
// ============================================================================
// TYPE RE-EXPORTS (zero runtime cost)
// ============================================================================
export type {
Category,
ConfigureOptions,
Filter,
FormatterFn,
LoggerConfig,
LogRecord,
Sink,
} from "./types.ts";
// Flat re-exports so callers can use `logging.Severities.Debug` and `logging.Severity`
export { Severities, SeverityNames } from "@eserstack/standards/logging";
export type { Severity, SeverityKey } from "@eserstack/standards/logging";