The silent observer for your Elysia applications
Tsuki (月) is a high-performance, runtime-adaptive logger for Elysia applications that combines the flexibility of Winston with the speed of Bun, while gracefully falling back to Node.js when needed.
- 🚀 Runtime Detection: Automatically detects and optimizes for Bun vs Node.js
- 🏗️ Modular Architecture: Clean separation of concerns with dedicated utilities
- 🔒 TypeScript Support: Full type safety throughout
- 🌐 Elysia Integration: Seamless Elysia plugin with HTTP request logging
- 📝 Standalone Usage: Can be used independently without Elysia
- 🎨 Custom Log Levels: success, critical, table, and standard levels
- 🌈 Color Support: Beautiful console output with chalk colors
- 📁 File Logging: Automatic log file creation with ANSI color stripping
- ⚡ Performance: Optimized for speed with lazy loading and caching
- 🧪 Tested: Comprehensive test suite with visual demonstrations
tsuki/
├── index.ts # Main exports
├── core/
│ ├── elysia-logger.ts # Elysia plugin implementation
│ └── standalone-logger.ts # Standalone logger implementation
├── types/
│ ├── index.ts # Re-export all types
│ ├── logger.types.ts # Logger interfaces & configs
│ ├── elysia.types.ts # Elysia-specific types
│ └── runtime.types.ts # Runtime detection types
├── utils/
│ ├── index.ts # Re-export all utils
│ ├── colors.ts # All color functions & constants
│ ├── formatters.ts # Winston formatters
│ ├── runtime.ts # Runtime detection & adapter
│ └── helpers.ts # General helper functions
├── tests/
│ ├── comprehensive.test.ts # Main test suite
│ ├── run-tests.ts # Test runner script
│ └── README.md # Test documentation
└── README.md
# Using Bun (recommended)
bun add tsuki-logger
# Using npm
npm install tsuki-logger
# Using yarn
yarn add tsuki-logger
# Using pnpm
pnpm add tsuki-logger
import { logger } from 'tsuki-logger';
// Basic logging
logger.info('Hello world');
logger.success('Operation completed');
logger.critical('Critical error occurred');
logger.debug('Debug information');
logger.error('Something went wrong');
logger.warning('Warning message');
// Table logging with visual output
logger.table('User data', {
name: 'John Doe',
age: 30,
city: 'New York'
});
import { Elysia } from 'elysia';
import { createLogger } from 'tsuki-logger';
const app = new Elysia()
.use(createLogger({
level: 'debug',
autoLogging: true,
customProps: (ctx) => ({
userId: ctx.headers['user-id'],
requestId: crypto.randomUUID()
})
}))
.get('/', () => 'Hello World')
.get('/users', () => ({ users: [] }))
.listen(3000);
import { createLogger } from 'tsuki-logger';
const logger = createLogger({
level: 'info',
autoLogging: {
ignore: (ctx) => ctx.path === '/health'
},
customProps: (ctx) => ({
userId: ctx.headers['user-id'],
ip: ctx.request.headers.get('x-forwarded-for'),
userAgent: ctx.request.headers.get('user-agent')
}),
logErrors: true
});
import { runtime } from 'tsuki-logger/utils';
console.log(`Running on: ${runtime.type}`); // 'bun' or 'node'
console.log(`Is Bun: ${runtime.isBun}`);
console.log(`Is Node: ${runtime.isNode}`);
// Use runtime-specific optimizations
if (runtime.isBun) {
console.log('Using Bun optimizations');
} else {
console.log('Using Node.js fallbacks');
}
import {
getMethodColor,
getStatusColor,
getColoredLevel
} from 'tsuki/utils';
// Color HTTP methods
console.log(getMethodColor('GET')); // Green GET
console.log(getMethodColor('POST')); // Blue POST
console.log(getMethodColor('DELETE')); // Red DELETE
// Color status codes
console.log(getStatusColor(200)); // Green 200
console.log(getStatusColor(404)); // Red 404
console.log(getStatusColor(500)); // Magenta 500
// Color log levels
console.log(getColoredLevel('info')); // Blue INFO
console.log(getColoredLevel('success')); // Green SUCCESS
console.log(getColoredLevel('error')); // Red ERROR
interface LoggerConfig {
level?: 'error' | 'critical' | 'warning' | 'info' | 'success' | 'debug' | 'table';
autoLogging?: boolean | { ignore?: (ctx: Context) => boolean };
customProps?: (ctx: Context) => Record<string, unknown>;
logErrors?: boolean;
}
error
(0) - Error messagescritical
(1) - Critical system errorswarning
(2) - Warning messagesinfo
(3) - General informationsuccess
(4) - Success messagesdebug
(5) - Debug informationtable
(6) - Table data logging
The Elysia logger automatically logs HTTP requests with:
- Colored HTTP methods (GET, POST, PUT, PATCH, DELETE)
- Status codes with appropriate colors
- Response times
- Request paths
- Custom arrows for different methods (→, ←, ×)
Example output:
[2025-09-20 16:15:43] INFO PUT ← 200 /api/users
[2025-09-20 16:15:43] ERROR GET → 404 /api/not-found
Logs are automatically written to .log/
directory:
log.txt
- All logslog.error.txt
- Error logs onlylog.debug.txt
- Debug logs only
File logs strip ANSI color codes for clean text output.
Tsuki includes a comprehensive test suite using Bun's built-in testing framework.
# Run all tests
bun run test
# Run tests in watch mode
bun run test:watch
# Run all test files
bun run test:all
# Run specific test file
bun test tests/comprehensive.test.ts
The test suite covers:
- ✅ Runtime Detection (Bun vs Node.js)
- ✅ Standalone Logger (all log levels)
- ✅ Elysia Integration
- ✅ Color Functions
- ✅ Visual Output Demo
- ✅ Error Handling
- ✅ Performance Testing (100 logs in ~3ms)
The tests include beautiful visual demonstrations showing:
- Colored log messages with timestamps
- Formatted tables with data
- Consistent styling across all levels
- Performance metrics
- Bun 1.2+ (recommended)
- Node.js 18+ (fallback)
- TypeScript 5.0+
# Clone the repository
git clone https://github.com/mohammedibrahim8887/tsuki.git
cd tsuki
# Install dependencies
bun install
# Run tests
bun run test
# Run tests in watch mode
bun run test:watch
core/
- Core logger implementationstypes/
- TypeScript type definitionsutils/
- Utility functions and helperstests/
- Test suite and documentation
# Build the project
bun run build
# Type check
bun run type-check
We welcome contributions! Please follow these guidelines:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature
- Make your changes
- Run tests:
bun run test
- Commit your changes:
git commit -m 'Add amazing feature'
- Push to the branch:
git push origin feature/amazing-feature
- Open a Pull Request
- Use TypeScript with strict type checking
- Follow the existing code structure and patterns
- Add tests for new features
- Update documentation as needed
- Use meaningful commit messages
- Ensure all tests pass
- Add tests for new functionality
- Update documentation if needed
- Request review from maintainers
- Address any feedback
- Use GitHub Issues for bug reports and feature requests
- Provide clear descriptions and reproduction steps
- Use appropriate labels
This project is licensed under the MIT License - see the LICENSE file for details.
- Winston - Logging library
- Elysia - Web framework
- Chalk - Terminal string styling
- Bun - JavaScript runtime
- 100 log calls: ~3ms execution time
- Runtime detection: Cached for performance
- Color functions: Optimized for speed
- File operations: Efficient Bun/Node.js adapters
Named after the Japanese word for moon (月), Tsuki silently watches over your applications, logging everything that happens under its watchful gaze. 🌙✨