GitXplorerGitXplorer
s

Arduino-SimpleSyslog

public
9 stars
2 forks
0 issues

Commits

List of commits on branch main.
Unverified
7ec93afd2570df7650d18dc35fc9281027e1e431

Update examples

sscottchiefbaker committed 2 years ago
Unverified
914872b767204285b15641eef8fcef7ef6a8a972

Expand docs with rsyslog info

sscottchiefbaker committed 2 years ago
Unverified
9a5aa0caa96baf2e11f6bac8e4fab661d19ee7be

Add syntax highlighting

sscottchiefbaker committed 2 years ago
Unverified
a75f964fe96cba5eecf4bfb970a5c4632e4dd201

README polish

sscottchiefbaker committed 2 years ago
Unverified
ff7ee84225c5a559eee4fbc68f4fd5528a4c3644

Merge branch 'main' of github.com:scottchiefbaker/Arduino-SimpleSyslog into main

sscottchiefbaker committed 2 years ago
Unverified
40e7ec7fcc50c9c3df0ed4ffba9263d1539b8b84

Add a README

sscottchiefbaker committed 2 years ago

README

The README file for this repository.

Arduino SimpleSyslog

Easily add remote syslog capabilities to your ESP32/ESP8266 projects.

Installation

Clone this repo to your Arduino libraries directory. On Linux this is ~/Arduino/libraries/. Alternately you can just drop SimpleSyslog.h in the same directory as your .ino script.

Usage

Include the SimpleSyslog library and create a global syslog object with your environment settings:

#include <SimpleSyslog.h>

SimpleSyslog syslog("ArduinoHostname", "ArduinoApp", "192.168.5.222");

Optional settings are port (default: 514) and maximum packet size (default: 128). To use port 5140 with a packet size of 400:

SimpleSyslog syslog("ArduinoHostname", "ArduinoApp", "192.168.5.222", 5140, 400);

Send a syslog message:

// Simple string syntax
syslog.printf(FAC_LOCAL7, PRI_INFO, "This is a simple LOCAL7.INFO syslog packet");

// Advanced printf() syntax supported also
syslog.printf(FAC_USER, PRI_DEBUG, "Uptime: %s", millis());

Valid facilities:

  • FAC_USER
  • FAC_LOCAL0
  • FAC_LOCAL1
  • FAC_LOCAL2
  • FAC_LOCAL3
  • FAC_LOCAL4
  • FAC_LOCAL5
  • FAC_LOCAL6
  • FAC_LOCAL7

Valid severities:

  • PRI_EMERGENCY
  • PRI_ALERT
  • PRI_CRITICAL
  • PRI_ERROR
  • PRI_WARNING
  • PRI_NOTICE
  • PRI_INFO
  • PRI_DEBUG

Configuring rsyslog to receive messages

You will need to configure your /etc/rsyslog.conf to accept incoming UDP syslog messages. Add these lines to your config and restart rsyslog

$ModLoad imudp
$UDPServerRun 514

You may want to configure a specific rule to handle your messages:

# /etc/rsyslog.d/arduino.conf
template(name="arduino" type="string" string="/var/log/arduino.log")

if ($syslogfacility-text == "local7" or $syslogfacility-text == "user") then {
    action(type="omfile" DynaFile="arduino" FileCreateMode="0644")
    stop
}

Based on

Borrowed from jerryr/EspSyslog and improved upon.