node-syslog

Modern Node.js syslog library with fluent TypeScript API for Linux systems.

npm version License: MIT Node.js Version

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.


Note: This package is designed for Linux systems only. For cross-platform logging, consider alternatives like Winston or Pino.