Skip to content

Repository files navigation

Terrier DataLog License

CLI Screenshoot

Terrier DataLog is a modern, fast and fully cross-platform CLI application, developed in C# (.NET 8), designed to manage logs, monitoring and data persistence in different environments — including Windows, Linux and (in the future) macOS.

Created with a focus on simplicity, efficiency and extensibility, Terrier DataLog offers a complete flow to start, stop and monitor background data collection processes, using an internal server with file-based communication (PID), in addition to supporting user-friendly configurations via YAML.

🚀 Key Features

✔ Truly Cross-Platform

Runs natively on:

  • Windows (x64)
  • Linux (x64, Debian-based)

Distributed as a self-contained single-file application with no external dependencies.


✔ Background Server

Terrier DataLog includes an internal background server that can be started and stopped directly through CLI commands:

terrier start
terrier stop
terrier status

Processes are fully isolated through:

  • User-local runtime directory
  • PID files
  • Dedicated logging system

✔ Simple YAML Configuration

The terrier configure command creates and manages a YAML configuration file containing:

  • SQLite database path
  • Endpoints
  • Tokens
  • Storage directories

✔ Built-In SQLite

Uses sqlite-net-pcl as the local database engine — efficient, lightweight, and ideal for desktop or server environments.


✔ Easy Installation

  • Install via .deb on Linux (Debian/Ubuntu based)
  • Install via .exe or extracted folder on Windows
  • Global terrier command available after installation

🔧 Use Cases

Terrier DataLog is ideal for:

  • Systems requiring continuous data collection (data logging)
  • Monitoring applications for sensors, equipment, or processes
  • Automation workflows that write into SQLite
  • Internal company tools needing a lightweight daemon
  • Developers wanting to embed a simple background “mini server”

🧩 Technologies Used

  • .NET 8 (C#)
  • Self-contained single-file CLI
  • SQLite via sqlite-net-pcl
  • YAML for configuration
  • Background process with PID control
  • .deb packaging for Linux distribution

Installation (Windows)

Download the official Windows x64 installer from the release page:

👉 https://github.com/micilini/TerrierDataLog/releases/tag/windows-x64-1.0.0

Run the installer and follow the setup steps.
After installation, the terrier command will be available globally in any terminal through the system PATH.


Installation (Debian/Linux)

Download the official Debian/Ubuntu .deb package:

👉 https://github.com/micilini/TerrierDataLog/releases/tag/debian-ubuntu-x64

Install the package using your system's package manager (e.g., double-click or dpkg -i).
Once installed, the terrier command becomes globally available in any terminal via the system PATH.

Commands

Command Description
terrier configure Create/edit configuration and test forwarder connections.
terrier status Shows health, queues, DB size, last rotation and service status.
terrier tail [--allApps] [--interval N] Follow logs in real time with refresh every N seconds.
terrier start Start the Terrier background application.
terrier end Stops the Terrier background application.
terrier restart Restarts the Terrier background application.

Flags

Flag Description
--json Outputs results as JSON.
--allApps In tail, includes logs from all app_id.
--interval N In tail, sets refresh interval in seconds (default: 2).
-r, --realtime In status, updates live every 1 second until Ctrl+C.

Tips

  • Use Ctrl+C to stop the tail.
  • Combine commands with --json for integration with external tools or UI interfaces.

First-Time Setup (terrier configure)

Before running TerrierDataLog for the first time, you must generate the initial configuration file.
This is done using:

terrier configure

The command will guide you interactively and create a config.yml inside your user-local data directory.
Each prompt includes a default value — just press ENTER to accept defaults.

Below is a detailed explanation of each field requested during the configuration process.


Configuration Fields Explained

Field / Prompt Default Value Purpose
server.http_listen 127.0.0.1:4925 HTTP listener used by Terrier's internal server. Required.
server.udp_listen 127.0.0.1:5514 UDP listener for receiving logs. Can be disabled by leaving it blank.
server.token auto-generated 16-byte hex token Authentication token required by clients sending data to Terrier.
server.limits.max_body_kb 1024 Maximum allowed body size (in KB) for incoming HTTP payloads.
server.limits.bulk_max_items 100 Max number of items allowed in a bulk insertion request.
storage.sqlite_path (auto-chosen inside AppData) Location of Terrier’s SQLite database. The file is created automatically.
storage.file_rotations.enabled Y Whether log rotation is enabled (archive older data).
storage.file_rotations.db_max_size_mb 512 Max DB size before rotation triggers (in MB). Applies only when rotation is enabled.
storage.file_rotations.dir (AppData/TerrierDataLog/archive) Directory where rotated/archived DB files are stored.
storage.file_rotations.period daily Rotation frequency: hourly or daily.
storage.file_rotations.compress Y Whether rotated files should be compressed.
storage.retention.max_days 14 Maximum number of days to keep old archived DB files.
storage.retention.max_size_mb 5120 Maximum total size (in MB) of archive files before pruning occurs.

After Configuring

When the configuration completes, TerrierDataLog will show:

  • The path where config.yml was saved
  • The generated server token
  • A note suggesting you run:
terrier status

This confirms that the configuration file is valid and readable.

Sample config.yml Output

Below is an example of a generated configuration file after running terrier configure:

server:
  httpListen: 127.0.0.1:4925
  udpListen: 127.0.0.1:5514
  token: 539074ea9378f29197d2187773d0fe28
  limits:
    maxBodyKb: 1024
    bulkMaxItems: 100

storage:
  sqlitePath: C:\Users\William Lima\AppData\Local\TerrierDataLog\terrier.db
  fileRotations:
    enabled: true
    dir: C:\Users\William Lima\AppData\Local\TerrierDataLog\archive
    period: daily
    compress: true
    dbMaxSizeMb: 3
  retention:
    maxDays: 14
    maxSizeMb: 5120

First Run (terrier start)

After completing the configuration step, you can launch the Terrier background server using:

terrier start

This command starts the internal runtime process responsible for handling log ingestion, health checks, archiving, and SQLite persistence.
Once running, Terrier exposes both HTTP and (optional) UDP endpoints defined in your config.yml.

You can verify if the service is active using:

terrier status

If the HTTP listener is active, Terrier will accept incoming log requests at the configured address and port.


Sending Requests to Terrier Endpoints

All HTTP requests must include the following headers:

Header Purpose
Accept: application/json Informs Terrier client expects a JSON response.
X-Terrier-Token: <your-token> Authentication token generated in config.yml.

Example:

Accept: application/json
X-Terrier-Token: 539074ea9378f29197d2187773d0fe28

Below are the available endpoints.


/healthz — Server Health Check

Checks if the Terrier background process is alive and responding.

Example request (curl):

curl -X GET http://127.0.0.1:4925/healthz \
  -H "Accept: application/json" \
  -H "X-Terrier-Token: 539074ea9378f29197d2187773d0fe28"

/logs — Send a Single Log Entry

This endpoint accepts a single JSON document representing one structured log.

Example Payload

{
  "app_id": "orchestrator",
  "level": "info",
  "title": "hello",
  "message": "world",
  "kv": { "foo": "bar" }
}

Example request (curl)

curl -X POST http://127.0.0.1:4925/logs \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "X-Terrier-Token: 539074ea9378f29197d2187773d0fe28" \
  -d '{
        "app_id": "orchestrator",
        "level": "info",
        "title": "hello",
        "message": "world",
        "kv": { "foo": "bar" }
      }'

/logs/bulk — Send Multiple Log Entries at Once

Used for batch ingestion. Accepts an array of log objects.

Example Payload

[
  {
    "app_id": "orchestrator",
    "level": "info",
    "title": "ok-1",
    "message": "m1"
  },
  {
    "app_id": "orchestrator",
    "level": "error",
    "title": "oops",
    "details": "..."
  },
  {
    "app_id": "",
    "level": "warn",
    "title": "missing-app"
  } // invalid: app_id cannot be empty
]

Example request (curl)

curl -X POST http://127.0.0.1:4925/logs/bulk \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -H "X-Terrier-Token: 539074ea9378f29197d2187773d0fe28" \
  -d '[ 
        { "app_id": "orchestrator", "level": "info", "title": "ok-1", "message": "m1" },
        { "app_id": "orchestrator", "level": "error", "title": "oops", "details": "..." },
        { "app_id": "", "level": "warn", "title": "missing-app" }
      ]'

Sending Logs via UDP (Optional Listener)

UDP is recommended for lightweight, non-critical, fast-fire log messages.

Example (PowerShell — Windows)

$endpointIp = "127.0.0.1"
$endpointPort = 5514

# Payload JSON
$payload = @{
    app_id  = "udp-tester"
    env     = "dev"
    level   = "info"
    title   = "UDP test"
    message = "Hello from UDP via PS1!"
} | ConvertTo-Json -Depth 3

# Convert to bytes
$bytes = [System.Text.Encoding]::UTF8.GetBytes($payload)

# Send via UDP
$client = New-Object System.Net.Sockets.UdpClient
$client.Send($bytes, $bytes.Length, $endpointIp, $endpointPort) | Out-Null
$client.Close()

Write-Host "UDP sent successfully!"

UDP Example on Linux

You can use socat or netcat (nc):

Example using nc:

echo '{"app_id":"udp-tester","level":"info","title":"linux-test","message":"Hello from Linux UDP"}' \
  | nc -w0 -u 127.0.0.1 5514

Example using socat:

echo '{"app_id":"udp-client","level":"info","title":"socat-test"}' \
  | socat - UDP:127.0.0.1:5514

UDP messages do not require headers or authentication tokens.


After sending logs, you can monitor incoming data using:

terrier tail

This displays real-time aggregated data from SQLite and the log buffer.

Real-Time Log Streaming (terrier tail)

CLI Screenshoot

terrier tail allows you to watch incoming logs in real time, directly from the TerrierDataLog SQLite pipeline.
It continuously follows new entries as they are written, similar to tail -f, but enriched with structured fields such as timestamps, log levels, app identifiers, and message metadata.

Usage is straightforward:

terrier tail

You can also enable full-application streaming or adjust the refresh interval:

terrier tail --allApps
terrier tail --interval 5

Press Ctrl+C at any time to exit the live stream.

This command is ideal for debugging, monitoring services, inspecting background workers, or validating real-time log ingestion during development.

Contribute

Want to help improve TerrierDataLog? You're welcome to contribute!

If you'd like to add new features, improve existing functionality, or submit translations or documentation updates, simply create a Pull Request (PR).
Bug fixes, enhancements, and quality-of-life improvements are also highly appreciated.

Feel free to open Issues as well if you have ideas, suggestions, or questions about future development.

License

TerrierDataLog is open-source and released under the MIT License.
You are free to use, modify, and distribute this project as long as you retain the original license notice.

About

TerrierDataLog is a cross-platform CLI tool built in .NET 8 for lightweight data logging and background process management. It provides simple YAML-based configuration, an integrated SQLite database engine, and commands to start, stop, and monitor a local runtime server on Windows or Linux.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages