Browse Source

Initial support for syslog messaging

rfm69
Xose Pérez 6 years ago
parent
commit
2060dd9661
3 changed files with 55 additions and 4 deletions
  1. +7
    -2
      code/espurna/config/general.h
  2. +36
    -0
      code/espurna/config/types.h
  3. +12
    -2
      code/espurna/debug.ino

+ 7
- 2
code/espurna/config/general.h View File

@ -1,4 +1,4 @@
//------------------------------------------------------------------------------
// // //------------------------------------------------------------------------------
// Do not change this file unless you know what you are doing // Do not change this file unless you know what you are doing
// Configuration settings are in the settings.h file // Configuration settings are in the settings.h file
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -75,9 +75,14 @@
#endif #endif
#ifndef DEBUG_UDP_PORT #ifndef DEBUG_UDP_PORT
#define DEBUG_UDP_PORT 8113
#define DEBUG_UDP_PORT 514
#endif #endif
// If DEBUG_UDP_PORT is set to 514 syslog format is assumed
// (https://tools.ietf.org/html/rfc3164)
// DEBUG_UDP_FAC_PRI is the facility+priority
#define DEBUG_UDP_FAC_PRI (SYSLOG_LOCAL0 | SYSLOG_DEBUG)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
#ifndef DEBUG_TELNET_SUPPORT #ifndef DEBUG_TELNET_SUPPORT


+ 36
- 0
code/espurna/config/types.h View File

@ -61,6 +61,42 @@
#define RELAY_PROVIDER_RFBRIDGE 3 #define RELAY_PROVIDER_RFBRIDGE 3
#define RELAY_PROVIDER_STM 4 #define RELAY_PROVIDER_STM 4
//------------------------------------------------------------------------------
// UDP SYSLOG
//------------------------------------------------------------------------------
// Priority codes:
#define SYSLOG_EMERG 0 /* system is unusable */
#define SYSLOG_ALERT 1 /* action must be taken immediately */
#define SYSLOG_CRIT 2 /* critical conditions */
#define SYSLOG_ERR 3 /* error conditions */
#define SYSLOG_WARNING 4 /* warning conditions */
#define SYSLOG_NOTICE 5 /* normal but significant condition */
#define SYSLOG_INFO 6 /* informational */
#define SYSLOG_DEBUG 7 /* debug-level messages */
// Facility codes:
#define SYSLOG_KERN (0<<3) /* kernel messages */
#define SYSLOG_USER (1<<3) /* random user-level messages */
#define SYSLOG_MAIL (2<<3) /* mail system */
#define SYSLOG_DAEMON (3<<3) /* system daemons */
#define SYSLOG_AUTH (4<<3) /* security/authorization messages */
#define SYSLOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
#define SYSLOG_LPR (6<<3) /* line printer subsystem */
#define SYSLOG_NEWS (7<<3) /* network news subsystem */
#define SYSLOG_UUCP (8<<3) /* UUCP subsystem */
#define SYSLOG_CRON (9<<3) /* clock daemon */
#define SYSLOG_AUTHPRIV (10<<3) /* security/authorization messages (private) */
#define SYSLOG_FTP (11<<3) /* ftp daemon */
#define SYSLOG_LOCAL0 (16<<3) /* reserved for local use */
#define SYSLOG_LOCAL1 (17<<3) /* reserved for local use */
#define SYSLOG_LOCAL2 (18<<3) /* reserved for local use */
#define SYSLOG_LOCAL3 (19<<3) /* reserved for local use */
#define SYSLOG_LOCAL4 (20<<3) /* reserved for local use */
#define SYSLOG_LOCAL5 (21<<3) /* reserved for local use */
#define SYSLOG_LOCAL6 (22<<3) /* reserved for local use */
#define SYSLOG_LOCAL7 (23<<3) /* reserved for local use */
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// MQTT // MQTT
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------


+ 12
- 2
code/espurna/debug.ino View File

@ -19,6 +19,9 @@ extern "C" {
#if DEBUG_UDP_SUPPORT #if DEBUG_UDP_SUPPORT
#include <WiFiUdp.h> #include <WiFiUdp.h>
WiFiUDP _udp_debug; WiFiUDP _udp_debug;
#if DEBUG_UDP_PORT == 514
char _udp_header[40] = {0};
#endif
#endif #endif
void _debugSend(char * message) { void _debugSend(char * message) {
@ -42,8 +45,8 @@ void _debugSend(char * message) {
if (systemCheck()) { if (systemCheck()) {
#endif #endif
_udp_debug.beginPacket(DEBUG_UDP_IP, DEBUG_UDP_PORT); _udp_debug.beginPacket(DEBUG_UDP_IP, DEBUG_UDP_PORT);
#if DEBUG_ADD_TIMESTAMP
_udp_debug.write(timestamp);
#if DEBUG_UDP_PORT == 514
_udp_debug.write(_udp_header);
#endif #endif
_udp_debug.write(message); _udp_debug.write(message);
_udp_debug.endPacket(); _udp_debug.endPacket();
@ -132,6 +135,13 @@ void debugSetup() {
} }
}); });
#if DEBUG_UDP_SUPPORT
#if DEBUG_UDP_PORT == 514
snprintf_P(_udp_header, sizeof(_udp_header), PSTR("<%u>%s ESPurna[0]: "), DEBUG_UDP_FAC_PRI, getSetting("hostname").c_str());
#endif
#endif
} }
#endif // DEBUG_WEB_SUPPORT #endif // DEBUG_WEB_SUPPORT


Loading…
Cancel
Save