Logixlysia

repository·main·Indexed 42 days ago

https://github.com/pungrumpy/logixlysia

A logging and observability framework for high-performance TypeScript environments like Bun and Elysia. It features AI metrics, OpenTelemetry integration, automatic PII redaction, and supports transports such as Axiom.

Tokens
61.7K
Snippets
235
Records
305
Agent score
54%

What's inside Logixlysia

  1. Overview of Logixlysia features

    main

    Logixlysia is a high-performance logging plugin for Elysia.js designed for production environments. Key capabilities include:

    • High Performance: A fast built-in console logger with minimal overhead.
    • Structured Logging: A JSON-first approach optimized for log analysis.
    • Flexible Configuration: Ability to customize log format, level, and output destinations.
    • File Logging: Support for saving logs to files with automatic rotation.
    • Transport Support: Capability to send logs to external services.
    • Type Safety: Full TypeScript support for a better developer experience.
  2. Understand how log rotation triggers work

    main

    Log rotation in logixlysia is triggered by two primary thresholds. Whichever threshold is crossed first will initiate the rotation process:

    1. Size-based (maxSize): Triggered when the current log file reaches a specific size.
    2. Time-based (interval): Triggered when the time elapsed since the file's creation (or last rotation) exceeds the configured interval.

    Both triggers follow a 'check-on-write' pattern. The system does not run continuous background timers; instead, it checks the rotation conditions every time a new log line is written to the sink.

  3. Use Logixlysia presets

    main

    Logixlysia provides predefined configurations via the preset option. Explicit config settings will override these defaults.

    • dev: Pretty console output with a startup banner.
    • prod: JSON logs with autoRedact enabled.
    • json: Minimal JSON console output.
    logixlysia({ preset: 'dev' })   // pretty console + banner
    logixlysia({ preset: 'prod' })  // JSON logs + autoRedact
    logixlysia({ preset: 'json' })  // minimal JSON console
  4. Deciding when to use Logixlysia

    main

    Choose Logixlysia if your requirements include:

    • Pino performance combined with Elysia-native store.logger ergonomics.
    • File logging and rotation capabilities that do not require configuring separate drains.
    • Incremental context management using mergeContext alongside automatic access logs (as opposed to a wide-event-only API).

    Consider evlog instead if:

    • You require a unified wide-event pipeline across multiple frameworks using managed drains (e.g., Axiom).
    • You specifically need the out-of-the-box evlog/ai and evlog auth integrations.
  5. Understand the Logixlysia project structure

    main

    Logixlysia is a monorepo managed with Bun workspaces and Turbo.

    Top-level structure

    • apps/docs/: Documentation site (Blume)
    • apps/elysia/: Playground demo (Bun + TypeScript + Swagger)
    • packages/logixlysia/: The core Logixlysia package
    • packages/bench/: Benchmarks
    • packages/typescript-config/: Shared TypeScript configurations

    Core package internals (packages/logixlysia/src/)

    • config/: Configuration resolution and presets
    • context/: Request context handling
    • extensions/: Additional features and extensions
    • helpers/: Utility functions
    • logger/: Core logging functionality
    • middleware/: Elysia middleware/plugin hooks
    • output/: Output handlers and formatters (console, file, rotation)
    • types/: TypeScript types
    • utils/: Shared utilities
    • websocket/: WebSocket support
    • ai.ts: AI-related helpers
    • errors.ts: Structured error handling
    • index.ts: Main entry point
    • interfaces.ts: TypeScript interfaces
    • otel.ts: OpenTelemetry integration
  6. Understand Logixlysia log level hierarchy

    main

    Logixlysia uses a hierarchical log level system to control verbosity. When a specific level is selected, all levels higher in the hierarchy (less verbose) are also captured.

    The hierarchy from most verbose to least verbose is: DEBUG > INFO > WARNING > ERROR

    For example, setting the level to WARNING will include both WARNING and ERROR messages in the output.

  7. Use root-relative paths for images in shared content

    main

    Because the documentation is shared between Blume and Mintlify, you must use root-relative image paths (e.g., /preview.png) to ensure images render in both systems.

    Mintlify does not support relative image paths. To support both, keep real image files in content/ or public/ and reference them from the root. Note that public/ should contain symlinks to the files in content/ so that Astro can dereference them during the build process.

  8. Understand the log data structure sent to adapters

    main

    Each log entry sent to an adapter includes the level, message, and a full meta object containing:

    • Request method and URL
    • Response status
    • durationMs
    • Merged request context (e.g., request IDs, trace IDs, user IDs, and custom fields).

    Data Formatting:

    • Flat-attribute platforms (e.g., HyperDX, Sentry, PostHog): Keys are converted to dot-notation (e.g., request.method, context.requestId).
    • Nested platforms (e.g., Axiom): The nested structure is preserved as-is.

    Note on Redaction: Redaction occurs before logs are sent to transports. Any configured autoRedact or redactKeys will apply to the data sent to your external platforms.

  9. Organize documentation content and sidebar ordering

    main

    Documentation pages are stored in the content/ directory as Markdown or MDX files and are served under the /docs path.

    • Sidebar Ordering: Folders in content/ become sidebar groups. The order is determined by a meta.ts file located beside the folder.
    • Mintlify Compatibility: While Blume uses meta.ts, Mintlify uses content/docs.json to order the same content tree. To prevent Blume-specific files from being processed by Mintlify, list them in content/.mintignore.
  10. Startup message formats: simple vs banner

    main

    Logixlysia supports two distinct visual formats for startup announcements:

    1. Simple Format: A clean, minimal single-line message. Example: 🦊 Logixlysia is running on http://localhost:3000

    2. Banner Format (Default): A large ASCII art box containing the version and the running URL. Example:

      ┌─────────────────────────────────────────────────┐
      │                                                 │
      │                 Elysia v1.4.19                  │
      │                                                 │
      │  🦊 Elysia is running at http://localhost:3001  │
      │                                                 │
      └─────────────────────────────────────────────────┘
  11. Understand the Sentry log payload format

    main

    Logs are posted to the Sentry envelope endpoint as log items. The following mapping is applied:

    • Body: The log message, or GET /path for access logs.
    • Level:
      • DEBUG → debug
      • INFO → info
      • WARNING → warn
      • ERROR → error
    • Attributes: Meta fields are flattened into typed attributes (string, integer, double, boolean). Examples include request.method, status, durationMs, and context.requestId.
    • Trace ID: Reused from context.trace_id if logixlysia/otel is used; otherwise, a new one is generated.

    You can filter logs in Sentry using these attributes (e.g., status:500 or context.requestId:0d5e…).