angelxmoreno / angelxmoreno/bun-sqlite-orm
[Feature]: Complete PinoDbLogger Implementation
- Dominant language
- TypeScript
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
**Problem Statement**
The current PinoDbLogger implementation is incomplete and shows a warning message: "PinoDbLogger is not fully implemented yet. Install pino as a peer dependency." This creates a poor developer experience and prevents users from leveraging structured logging with Pino in production environments.
Users who want to use Pino for structured logging are currently forced to use the console fallback implementation, missing out on Pino's performance benefits and advanced logging features.
**Proposed Solution**
Complete the PinoDbLogger implementation with full Pino integration:
1. **Proper Pino Integration**: Replace console fallback with actual Pino logger
2. **Configuration Options**: Support for Pino logger configuration
3. **Log Levels**: Proper mapping of debug, info, warn, error levels
4. **Structured Logging**: Leverage Pino's structured logging capabilities
5. **Performance**: Utilize Pino's high-performance logging
6. **File Outputs**: Support for file-based logging when configured
**Example Usage**
```typescript
import { PinoDbLogger } from 'bun-sqlite-orm';
import pino from 'pino';
// Basic usage
const logger = new PinoDbLogger({
level: 'info',
writeToFile: true,
fileName: 'orm.log'
});
// Advanced usage with custom Pino instance
const customPino = pino({
transport: {
target: 'pino-pretty',
options: {
colorize: true,
translateTime: 'SYS:standard'
}
}
});
const logger = new PinoDbLogger({
pinoInstance: customPino,
level: 'debug'
});
// Use with DataSource
const dataSource = new DataSource({
database: './app.db',
entities: [User],
logger: logger
});
```
**Alternatives Considered**
1. **Remove PinoDbLogger**: Could remove the incomplete implementation entirely
2. **External Logger Interface**: Provide generic logger interface for users to implement their own Pino integration
3. **Multiple Logger Implementations**: Create separate packages for different logger integrations
**Impact**
- [ ] Query API
- [ ] Entity definitions
- [ ] Validation
- [ ] Migrations
- [x] Performance
- [x] TypeScript types
- [x] Documentation
**Additional Context**
- Pino is one of the fastest JSON loggers for Node.js/Bun
- Structured logging is important for production monitoring and debugging
- The current placeholder implementation creates technical debt
- Should maintain backward compatibility with existing PinoDbLogger usage
**Implementation Notes**
- Add pino as a peer dependency
- Implement proper error handling when pino is not installed
- Provide clear installation instructions in documentation
- Ensure structured log format is consistent with ORM operations
**Priority**: Medium - Improves production logging capabilities
Contributor guide
Research direction
Start by locating the PinoDbLogger implementation and its integration with DataSource, then review the existing logger behavior and TypeScript types. Check how the current console fallback handles log levels and missing pino. Done means documented configuration, working Pino integration, file output behavior, and preserved compatibility, with tests covering the supported options.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- backend, observability-sre
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100