node-syslog
Modern Node.js syslog library with fluent TypeScript API for Linux systems.
A modern, TypeScript-native replacement for the deprecated node-syslog package. Built with N-API for cross-platform binary compatibility and featuring a fluent, synchronous API.
âĻ Features
- Modern TypeScript: Full type safety with strict mode
- N-API Native: Pre-built binaries for ARM64/AMD64 Linux
- Fluent API: Clean, chainable interface
- Zero Dependencies: Runtime footprint < 50KB
- Synchronous Only: Direct kernel syslog(3) calls (non-blocking)
- Linux Optimized: Designed specifically for Linux syslog systems
ð Quick Start
Installation
npm install node-syslog
Basic Usage
import { Syslog } from 'node-syslog'
// Create logger instance
const logger = new Syslog({
ident: 'myapp',
facility: 'local0',
options: ['pid', 'odelay']
})
// Log messages
logger.info('Server started', { port: 3000 })
logger.error('Connection failed', { code: 'ECONNREFUSED' })
logger.debug('Debug information', { userId: 123 })
// Close when done
logger.close()
Advanced Configuration
import { Syslog, SyslogFacility, SyslogLevel, SyslogOption } from 'node-syslog'
const logger = new Syslog({
ident: 'production-app',
facility: SyslogFacility.DAEMON,
options: [SyslogOption.PID, SyslogOption.NDELAY, SyslogOption.LOG_PID],
logLevel: SyslogLevel.INFO
})
// Structured logging
logger.warning('High memory usage', {
memoryUsage: process.memoryUsage(),
threshold: '500MB'
})
ðïļ Architecture
âââââââââââââââââââââââââââââââââââââââââââââââ
â TypeScript API Layer (src/index.ts) â
â Fluent class, input validation, types â
âââââââââââââââââââââââââââââââââââââââââââââââĪ
â N-API C++ Bridge (src/binding.cpp) â
â Direct type conversion, no threadpool â
âââââââââââââââââââââââââââââââââââââââââââââââĪ
â C Implementation (src/syslog.c) â
â Direct syslog(3) calls, zero allocations â
âââââââââââââââââââââââââââââââââââââââââââââââ
ð Documentation
ð§ Requirements
- Node.js: >= 22.x LTS
- Platform: Linux only
- Architecture: ARM64 or AMD64
- System: rsyslog or syslog-ng (optional)
ð Performance
- Latency: < 1Ξs overhead vs raw syslog(3)
- Throughput: > 500,000 messages/second
- Memory: Zero allocations in hot path
- Binary Size: < 50KB per architecture
ðĪ Contributing
Contributions are welcome! Please see our Contributing Guide for details.
ð License
MIT License - see LICENSE file for details.
ð Links
Note: This package is designed for Linux systems only. For cross-platform logging, consider alternatives like Winston or Pino.