public final class LogContext implements AutoClosable:
Scoped structured logging context.
Context values are associated with the current Klyn thread and are merged into every event emitted inside the scope. Nested scopes inherit the outer values and explicit logger fields take final precedence.
import klyn.logging
try context = Logs.context(requestId = "req-42"):
LogManager.getLogger("http").info("Request received")| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | activeactive as Boolean: |
Whether this scope is still installed. |
| public readonly property | fieldsfields as LogFields: |
Structured fields owned by this exact scope. |
| public readonly property | spanIdspanId as String: |
Span identifier associated with this scope. |
| public readonly property | traceIdtraceId as String: |
Trace identifier associated with this scope. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | LogContextLogContext(fields as Map<String, Object> = null): |
Opens a context containing the supplied fields. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | closeclose() as Void: |
Closes this scope. |