Skip to content

API Reference

Complete API documentation for @sylphx/cat.

Core

  • Logger - Logger creation and methods
  • Types - TypeScript types and interfaces

Formatting

Output

  • Transports - Console, File, Stream, and OTLP transports

Middleware

  • Plugins - Context, Tracing, Redaction, and Sampling plugins

Utilities

Quick Reference

Import

typescript
import {
  createLogger,
  jsonFormatter,
  prettyFormatter,
  consoleTransport,
  fileTransport,
  streamTransport,
  otlpTransport,
  contextPlugin,
  tracingPlugin,
  redactionPlugin,
  tailSamplingPlugin,
  samplingPlugin,
  serializeError,
  requestSerializer,
  responseSerializer,
  autoSerializeErrors
} from '@sylphx/cat'

Create Logger

typescript
const logger = createLogger(options?: LoggerOptions): Logger

See Logger API for details.

Log Methods

typescript
logger.trace(message: string, data?: Record<string, unknown>): void
logger.debug(message: string, data?: Record<string, unknown>): void
logger.info(message: string, data?: Record<string, unknown>): void
logger.warn(message: string, data?: Record<string, unknown>): void
logger.error(message: string, data?: Record<string, unknown>): void
logger.fatal(message: string, data?: Record<string, unknown>): void

Type Hierarchy

Logger
├── LoggerOptions
│   ├── level?: LogLevel
│   ├── formatter?: Formatter
│   ├── transports?: Transport[]
│   ├── plugins?: Plugin[]
│   ├── context?: Record<string, unknown>
│   ├── batch?: boolean
│   ├── batchSize?: number
│   └── batchInterval?: number
├── LogEntry
│   ├── level: LogLevel
│   ├── timestamp: number
│   ├── message: string
│   └── data?: Record<string, unknown>
└── LogLevel
    ├── 'trace'
    ├── 'debug'
    ├── 'info'
    ├── 'warn'
    ├── 'error'
    └── 'fatal'

See Also

Released under the MIT License.