Add logging over the network to a syslog server

This has been tested successfully. FIXME: Don't hardcode IP address, use m_INetworkSyslogServerIPAddress instead

Thanks @rsta
https://github.com/rsta2/circle/tree/master/sample/33-syslog
network
probonopd 5 days ago
parent 9a6c782e3f
commit a9921e47b2
  1. 6
      src/config.cpp
  2. 2
      src/config.h
  3. 14
      src/minidexed.cpp
  4. 1
      src/minidexed.ini

@ -209,6 +209,7 @@ void CConfig::Load (void)
m_INetworkSubnetMask = m_Properties.GetIPAddress("NetworkSubnetMask") != 0; m_INetworkSubnetMask = m_Properties.GetIPAddress("NetworkSubnetMask") != 0;
m_INetworkDefaultGateway = m_Properties.GetIPAddress("NetworkDefaultGateway") != 0; m_INetworkDefaultGateway = m_Properties.GetIPAddress("NetworkDefaultGateway") != 0;
m_INetworkDNSServer = m_Properties.GetIPAddress("NetworkDNSServer") != 0; m_INetworkDNSServer = m_Properties.GetIPAddress("NetworkDNSServer") != 0;
m_INetworkSyslogServerIPAddress = m_Properties.GetIPAddress("NetworkSyslogServerIPAddress") != 0;
} }
unsigned CConfig::GetToneGenerators (void) const unsigned CConfig::GetToneGenerators (void) const
@ -767,3 +768,8 @@ CIPAddress CConfig::GetNetworkDNSServer (void) const
{ {
return m_INetworkDNSServer; return m_INetworkDNSServer;
} }
CIPAddress CConfig::GetNetworkSyslogServerIPAddress (void) const
{
return m_INetworkSyslogServerIPAddress;
}

@ -248,6 +248,7 @@ public:
CIPAddress GetNetworkSubnetMask (void) const; CIPAddress GetNetworkSubnetMask (void) const;
CIPAddress GetNetworkDefaultGateway (void) const; CIPAddress GetNetworkDefaultGateway (void) const;
CIPAddress GetNetworkDNSServer (void) const; CIPAddress GetNetworkDNSServer (void) const;
CIPAddress GetNetworkSyslogServerIPAddress (void) const;
private: private:
CPropertiesFatFsFile m_Properties; CPropertiesFatFsFile m_Properties;
@ -372,6 +373,7 @@ private:
CIPAddress m_INetworkSubnetMask; CIPAddress m_INetworkSubnetMask;
CIPAddress m_INetworkDefaultGateway; CIPAddress m_INetworkDefaultGateway;
CIPAddress m_INetworkDNSServer; CIPAddress m_INetworkDNSServer;
CIPAddress m_INetworkSyslogServerIPAddress;
}; };
#endif #endif

@ -23,6 +23,8 @@
#include <circle/sound/pwmsoundbasedevice.h> #include <circle/sound/pwmsoundbasedevice.h>
#include <circle/sound/i2ssoundbasedevice.h> #include <circle/sound/i2ssoundbasedevice.h>
#include <circle/sound/hdmisoundbasedevice.h> #include <circle/sound/hdmisoundbasedevice.h>
#include <circle/net/syslogdaemon.h>
#include <circle/net/ipaddress.h>
#include <circle/gpiopin.h> #include <circle/gpiopin.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -2326,6 +2328,18 @@ bool CMiniDexed::InitNetwork()
} }
m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType); m_pNetDevice = CNetDevice::GetNetDevice(NetDeviceType);
// Syslog configuration
static const u8 SysLogServer[] = {192, 168, 0, 143}; // FIXME: Don't hardcode this, use m_INetworkSyslogServerIPAddress instead
static const u16 usServerPort = 8514; // standard port is 514
CIPAddress ServerIP (SysLogServer);
CString IPString;
ServerIP.Format (&IPString);
LOGNOTE ( "Sending log messages to %s:%u",
(const char *) IPString, (unsigned) usServerPort);
new CSysLogDaemon (m_pNet, ServerIP, usServerPort);
} }
return m_pNet != nullptr; return m_pNet != nullptr;
} }

@ -153,6 +153,7 @@ NetworkIPAddress=0
NetworkSubnetMask=0 NetworkSubnetMask=0
NetworkDefaultGateway=0 NetworkDefaultGateway=0
NetworkDNSServer=0 NetworkDNSServer=0
NetworkSyslogServerIPAddress=0
# Performance # Performance
PerformanceSelectToLoad=1 PerformanceSelectToLoad=1

Loading…
Cancel
Save