| Crates.io | systemprompt-logging |
| lib.rs | systemprompt-logging |
| version | 0.0.11 |
| created_at | 2026-01-21 17:52:13.182579+00 |
| updated_at | 2026-01-25 21:42:04.597644+00 |
| description | Core logging module for systemprompt.io OS |
| homepage | https://systemprompt.io |
| repository | https://github.com/systempromptio/systemprompt-core |
| max_upload_size | |
| id | 2059792 |
| size | 258,621 |
Core logging module for systemprompt.io OS.
Part of the Infra layer in the systemprompt.io architecture.
This crate provides a dual-layer logging architecture combining console output with PostgreSQL persistence. It includes async batch processing, automatic context propagation, retention policies, and rich CLI output utilities.
Key Features:
src/
├── lib.rs - Entry point: init_logging(), init_console_logging()
│
├── layer/
│ ├── mod.rs - DatabaseLayer: async batch persistence to PostgreSQL
│ └── visitor.rs - FieldVisitor, SpanVisitor for field extraction
│
├── models/
│ ├── mod.rs - Re-exports
│ ├── log_entry.rs - LogEntry struct with builder pattern
│ ├── log_error.rs - LoggingError enum (thiserror)
│ ├── log_filter.rs - LogFilter for paginated queries
│ ├── log_level.rs - LogLevel enum (ERROR, WARN, INFO, DEBUG, TRACE)
│ └── log_row.rs - LogRow for SQLx database mapping
│
├── repository/
│ ├── mod.rs - LoggingRepository: CRUD with terminal/database output
│ ├── analytics/
│ │ └── mod.rs - AnalyticsRepository, AnalyticsEvent
│ └── operations/
│ ├── mod.rs - Re-exports
│ ├── queries.rs - get_log, list_logs, list_logs_paginated, count_logs
│ └── mutations.rs - create_log, update_log, delete_log, cleanup_old_logs
│
├── services/
│ ├── mod.rs - Re-exports
│ ├── database_log.rs - DatabaseLogService: implements LogService trait
│ ├── format.rs - FilterSystemFields: filters "system" from console output
│ ├── maintenance.rs - LoggingMaintenanceService: cleanup operations
│ │
│ ├── cli/
│ │ ├── mod.rs - Module declarations and re-exports
│ │ ├── display.rs - Display traits, DisplayUtils, StatusDisplay, CollectionDisplay
│ │ ├── macros.rs - cli_success!, cli_warning!, cli_error!, cli_info! macros
│ │ ├── module.rs - ModuleDisplay, ModuleInstall, ModuleUpdate
│ │ ├── prompts.rs - Prompts, PromptBuilder, QuickPrompts
│ │ ├── service.rs - CliService: logging facade (success, warning, error, etc.)
│ │ ├── startup.rs - Startup banner and phase rendering functions
│ │ ├── summary.rs - ValidationSummary, OperationResult, ProgressSummary
│ │ ├── table.rs - Table rendering, ServiceTableEntry, render_service_table
│ │ ├── theme.rs - Theme, Icons, Colors, BrandColors, ServiceStatus
│ │ └── types.rs - ItemStatus, ModuleType, MessageLevel, IconType, ColorType
│ │
│ ├── output/
│ │ └── mod.rs - Startup mode: is_startup_mode(), set_startup_mode()
│ │ Log publisher: publish_log(), set_log_publisher()
│ │
│ ├── retention/
│ │ ├── mod.rs - Re-exports
│ │ ├── policies.rs - RetentionPolicy, RetentionConfig (per-level retention)
│ │ └── scheduler.rs - RetentionScheduler: cron-based cleanup (daily 2AM)
│ │
│ └── spans/
│ └── mod.rs - RequestSpan, SystemSpan, RequestSpanBuilder
│
├── trace/
│ ├── mod.rs - Re-exports
│ ├── models.rs - TraceEvent, TaskInfo, ExecutionStep, AiRequestInfo,
│ │ McpToolExecution, ConversationMessage, ToolLogEntry
│ ├── service.rs - TraceQueryService: generic trace querying
│ ├── queries.rs - SQL queries for log events and AI request summaries
│ ├── step_queries.rs - SQL queries for MCP executions and execution steps
│ ├── ai_trace_service.rs - AiTraceService: AI/MCP operation tracing
│ ├── ai_trace_queries.rs - SQL queries for tasks, AI requests, messages
│ └── mcp_trace_queries.rs - SQL queries for MCP executions, tool logs, artifacts
│
schema/
├── log.sql - logs table, indexes, analytical views
└── analytics.sql - analytics_events table with GIN indexes
init_logging(db_pool) - Initialize with database persistenceinit_console_logging() - Initialize console-only loggingLogEntry - Log entry with metadata and context IDsLogLevel - Enum: ERROR, WARN, INFO, DEBUG, TRACELogFilter - Pagination and filtering for queriesLoggingError - Error type for logging operationsDatabaseLayer - Tracing layer for async database persistenceLoggingRepository - CRUD operations for logsAnalyticsRepository - Analytics event trackingAnalyticsEvent - Structured analytics eventDatabaseLogService - Implements LogService trait from systemprompt-traitsLoggingMaintenanceService - Log cleanup and maintenanceCliService - Rich CLI output facadeFilterSystemFields - Console field filterRequestSpan - For user-initiated operationsSystemSpan - For internal/background operationsRequestSpanBuilder - Fluent builder for request spansRetentionConfig - Per-level retention configurationRetentionPolicy - Individual retention policyRetentionScheduler - Cron-based cleanup schedulerTraceQueryService - Generic trace queryingAiTraceService - AI/MCP operation tracingTraceEvent, TaskInfo, ExecutionStep, AiRequestInfoMcpToolExecution, ConversationMessage, ToolLogEntryis_startup_mode(), set_startup_mode() - Startup mode controlpublish_log(), set_log_publisher() - Log event publishingsystemprompt-database - Database pool managementsystemprompt-traits - Shared trait definitions (LogService)systemprompt-identifiers - Typed identifiers (UserId, SessionId, etc.)tracing, tracing-subscriber - Structured logging frameworktokio - Async runtimesqlx - Type-safe SQLchrono - Timestamp handlingtokio-cron-scheduler - Retention job schedulingcolored, console, indicatif, dialoguer - CLI utilitiesAdd to your Cargo.toml:
[dependencies]
systemprompt-logging = "0.0.1"
FSL-1.1-ALv2 - See LICENSE for details.