Skip to content

Latest commit

 

History

History
249 lines (189 loc) · 7.28 KB

File metadata and controls

249 lines (189 loc) · 7.28 KB

Noisyaf

Your logs have been silent for too long.

Turn your terminal into a sensory battlefield where every ERROR screams, every WARNING hums with tension, and your CPU spikes play like a frantic synthesizer solo. Pipe your chaos through noisyaf and finally hear what your systems are trying to tell you.

Because sometimes you need to feel the pain of a 500 error in your bones, or know that your database is crying without looking at another dashboard.

Features

  • Multi-modal output: Sound, terminal colors, MIDI, or combinations
  • Pattern matching: Regex-based rules with YAML configuration
  • Real-time processing: Low-latency async processing with backpressure handling
  • Built-in classifications: Automatic detection of ERROR/WARN/INFO/CPU patterns
  • Graceful shutdown: Clean resource cleanup on SIGINT/SIGTERM
  • Stress testing: Built-in synthetic log generator for testing

Installation

git clone <repository-url>
cd noisyaf
cargo build --release

The binary will be available at target/release/noisyaf.

Quick Start

# Basic sound output (default)
echo "ERROR: disk full" | noisyaf

# Sound + color mode
journalctl -f | noisyaf color

# MIDI output
noisyaf midi --stress --duration 10

# List available audio devices
noisyaf --list-devices

# List MIDI ports  
noisyaf --midi-list

Usage

noisyaf [OPTIONS] [MODE]

Arguments:
  [MODE]  Mode: sound (default), color (sound+color), midi, or midicolor (midi+color) [default: sound]

Key Options:
      --passthrough           Pass input lines through to stdout
      --no-color             Disable colored output
      --volume <VOLUME>      Master volume for sound mode (0.0 - 1.0) [default: 0.5]
      --rowdy                Make ALL lines produce sound/MIDI, not just errors/warnings
      --device <DEVICE>      Output device name (substring match)
      --test-tone            Play a short test tone on startup
      --midi-port <MIDI_PORT> MIDI output port (substring match)
      --midi-channel <MIDI_CHANNEL> Default MIDI channel (0-15) [default: 0]
      --midi-velocity <MIDI_VELOCITY> Default MIDI velocity (1-127) [default: 100]
      --rules <RULES>        Load mapping rules from YAML file
      --no-defaults          Ignore built-in default mappings; use only rules.yaml
      --stress               Generate synthetic demo noise instead of reading stdin
      --list-devices         List available audio devices and exit
      --midi-list           List MIDI output ports and exit

Run 'noisyaf --help' for complete options list.

Built-in Pattern Recognition

Without custom rules, the app recognizes:

  • ERROR/PANIC/EXCEPTION: Red background, 220Hz tone, MIDI note 40
  • WARN/TIMEOUT/FAIL: Yellow text, 440Hz tone, MIDI note 52
  • INFO/STARTED/READY: Cyan text, 880Hz tone, MIDI note 64
  • CPU usage: Dynamic frequency based on percentage, color-coded alerts

Custom Rules

Create a YAML file to define custom patterns. See example-config.yaml for a comprehensive real-world configuration.

Simple Example

# rules.yaml
rules:
  - match: "\\[CRITICAL\\]"
    color: "white"
    bg: "darkred" 
    bold: true
    freq: 150.0
    duration_ms: 1000
    midi_note: 30
    midi_velocity: 127

  - match: "database.*slow"
    color: "yellow"
    freq: 300.0
    duration_ms: 400
    midi_note: 45
    midi_channel: 1

Real-World Configuration Strategy

For practical monitoring, consider this sonic hierarchy:

  • Critical errors (crashes, security): Deep bass tones (110-220Hz), long duration, loud
  • Warnings (HTTP errors, timeouts): Mid-range tones (330-440Hz), medium duration
  • Info events (service starts, logins): Higher pleasant tones (520-780Hz), short duration
  • Routine activity (web requests, processes): Very high, quiet tones (1000Hz+), brief
  • Rowdy mode (everything else): Subtle background pulse (200Hz, 100ms, quiet)

Use with:

noisyaf color --rules example-config.yaml --rowdy --volume 0.3

Rule Properties

  • match: Regex pattern (required)
  • color: Text color (black, red, green, yellow, blue, magenta, cyan, white, grey)
  • bg: Background color (same options as color)
  • bold: Bold text (true/false)
  • freq: Sound frequency in Hz
  • duration_ms: Sound/MIDI duration in milliseconds
  • midi_note: MIDI note number (0-127)
  • midi_channel: MIDI channel (0-15)
  • midi_velocity: MIDI velocity (1-127)

Examples

Monitor system logs

journalctl -f | noisyaf color --volume 0.3

Debug application with custom rules

tail -f app.log | noisyaf midicolor --rules debug-rules.yaml

Test with synthetic data

# Generate mixed log levels for 30 seconds
noisyaf sound --stress --rate 150 --duration 30 --err-pct 10 --warn-pct 20

Audio device selection

# List devices
noisyaf --list-devices

# Use specific device
noisyaf sound --device "USB Audio" --test-tone

MIDI setup

# List MIDI ports
noisyaf --midi-list

# Connect to specific port
noisyaf midi --midi-port "FluidSynth" --stress

Real-world monitoring with custom config

# Complete system monitoring - errors are dramatic, routine activity is subtle
journalctl -f | noisyaf color --rules example-config.yaml --rowdy --volume 0.3

# Web server monitoring - HTTP errors stand out, requests create background pulse
tail -f /var/log/nginx/access.log /var/log/nginx/error.log | noisyaf midi --rules example-config.yaml --rowdy

# Application development - hear your app's behavior in real-time
docker logs -f myapp 2>&1 | noisyaf color --rules example-config.yaml --rowdy --volume 0.2

Rowdy mode (everything makes noise)

# Make every log line produce sound - great for high-activity monitoring
tail -f busy-app.log | noisyaf sound --rowdy --volume 0.2

# Rowdy mode with MIDI - turn your logs into a continuous beat
noisyaf midi --rowdy --stress --rate 50

MIDI Testing

To test MIDI output, you'll need a software synthesizer:

Linux

# Install FluidSynth
sudo apt install fluidsynth fluid-soundfont-gm

# Start with soundfont
fluidsynth -a alsa -g 0.5 /usr/share/sounds/sf2/FluidR3_GM.sf2

# In another terminal
noisyaf midi --stress

macOS

# Use built-in Audio MIDI Setup or install FluidSynth
brew install fluidsynth

# Test with built-in synthesizer
noisyaf midi --stress

Performance

  • Backpressure handling: Configurable queue sizes prevent memory issues
  • Async processing: Non-blocking MIDI and efficient I/O
  • Resource monitoring: Automatic reporting of dropped events
  • Clean shutdown: Graceful cleanup on interruption

Queue tuning:

# Increase capacity for high-throughput logs
noisyaf color --queue-capacity 4096 --drop-log-interval 10

Architecture

  • Input processing: Async line-by-line stdin reading
  • Pattern matching: Compiled regex rules with first-match-wins priority
  • Audio output: Rodio-based tone generation with device selection
  • MIDI output: Async midir integration with note scheduling
  • Signal handling: Cross-platform graceful shutdown (SIGINT/SIGTERM/Ctrl+C)

Dependencies

  • tokio: Async runtime
  • rodio: Cross-platform audio
  • midir: Cross-platform MIDI
  • crossterm: Terminal colors
  • clap: CLI parsing
  • serde_yaml: Rules configuration
  • regex: Pattern matching

License

MIT License