Module @tscommon/logger
Type Aliases§
Source§type Log Payload = Record<string, unknown>
type Log Payload = Record<string, unknown>
Additional data to be logged.
Example:
{ port: 3000 }
{ error: new Error('Something went wrong.') }
{ status: 500, error: new Error('Something went wrong.') }
Deeply nested data:
{ user: { id: 1, name: 'Alice', friends: [{ id: 2, name: 'Bob' }] } }
// If maximum depth of the data to collect is 2.
{ user: { id: 1, name: 'Alice', friends: '[[Truncated]]' } }
Enumerations§
- LogLevel
Defines the severity levels for log entries.
Classes§
- Logger
A logger for writing log entries with various severity levels.
- LogWriter
A log writer that writes log entries to the console. You can extend this class to implement custom log writers that write to files, databases, or other destinations.
Interfaces§
- ILogger
- ILogWriter
- LogEntry
- LogTimestamp
Represents a timestamp for a log entry. The timestamp is a Unix epoch time with nanosecond precision. The timestamp is generated when the
LogTimestamp
object is created. The timestamp is immutable. The timestamp is represented as a string in the formatYYYY-MM-DDTHH:MM:SS.NNNNNNNNNZ
.
A map of key-value pairs that provides additional context to a log entry.
Example: