How pungrumpy/logixlysia works
Project Type and Purpose
• This is an open-source logging library (plugin) named Logixlysia for the ElysiaJS framework, accompanied by a documentation website built with Next.js (in the website/ folder).
• The core library lives under src/, with submodules for extensions, helpers, interfaces, logger logic, and output transports. There is a comprehensive test suite under __tests__/. The website/ directory is a standalone doc site.
Main Components
A. Consumer Application (ElysiaJS)
• Your user’s web or API server that installs logixlysia as a plugin via .use(logixlysia(config)).
B. Logixlysia Core Library
1. Extensions (src/extensions)
• Entry points (start-server.ts) to hook into Elysia lifecycle (e.g., show startup message).
2. Helpers (src/helpers)
3. Interfaces (src/interfaces)
4. Logger (src/logger)
• Core logging logic: building log messages, filtering, error handling.
5. Output (src/output)
• Transports: console, file, rotation management (rotation-manager.ts).
6. Utils (src/utils)
• Shared helpers (e.g., rotation logic).
C. Configuration
• User-supplied in the logixlysia({ config: { … } }) call. Drives: formatting, transports, filters, rotation.
D. File System
• Writes rotated logs to disk; cleans up old files.
E. Testing Suite (__tests__)
• Tests organized by feature: extensions, logger, output, helpers.
F. Documentation Website (website/)
• Next.js 13 app with MDX-based docs, search API, UI components, layout, styles.
Relationships and Interactions
1. App → Plugin: Elysia app loads plugin with config.
2. Plugin (Extensions) attach to request/response pipelines.
3. On each HTTP request/response:
• Helpers gather metadata (method, path, status, timestamp, IP).
• Logger formats the message, applies filters.
• Output transports receive the formatted log:
• Console transport prints to stdout.
• File transport writes to disk; rotation manager handles size/time-based rotation and compression.
4. Tests invoke library functions in isolation to verify behavior.
5. Website is independent: it pulls from website/content, MDX components, and delivers docs via Next.js routes.
Architectural Patterns and Principles
• Plugin/Middleware Architecture: Clean separation between core (logger logic) and integration layer (Elysia extensions).
• Strategy Pattern for transports: console vs. file vs. rotation manager all implement a common interface.
• Single Responsibility: helpers for utilities, interfaces for types, logger for message construction, output for side-effects.
• Configuration-Driven behavior: flexibility via a unified config object.