fix for syslog
This commit is contained in:
parent
801dbee4e1
commit
ff1da92dc8
3 changed files with 13 additions and 6 deletions
|
@ -942,7 +942,10 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
|||
}
|
||||
#endif
|
||||
else if (parts[0] == "setsl" && parts.size() == 3) {
|
||||
setloghost(parts.at(1).c_str(), parse_ll(parts[2]));
|
||||
if (setloghost(parts.at(1).c_str(), parse_ll(parts[2])) == false)
|
||||
cnsl->put_string_lf("Failed parsing IP address");
|
||||
else
|
||||
send_syslog(info, "Hello, world!");
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -1011,7 +1014,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
|||
"ser - serialize state to a file",
|
||||
// "dser - deserialize state from a file",
|
||||
#endif
|
||||
"dp - stop panel",
|
||||
"dp - disable panel",
|
||||
#if defined(ESP32)
|
||||
"cfgnet - configure network (e.g. WiFi)",
|
||||
"startnet - start network",
|
||||
|
|
9
log.cpp
9
log.cpp
|
@ -54,16 +54,19 @@ void setlogfile(const char *const lf, const log_level_t ll_file, const log_level
|
|||
atexit(closelog);
|
||||
}
|
||||
|
||||
void setloghost(const char *const host, const log_level_t ll)
|
||||
bool setloghost(const char *const host, const log_level_t ll)
|
||||
{
|
||||
inet_aton(host, &syslog_ip_addr.sin_addr);
|
||||
syslog_ip_addr.sin_port = htons(514);
|
||||
syslog_ip_addr.sin_family = AF_INET;
|
||||
bool ok = inet_aton(host, &syslog_ip_addr.sin_addr) == 1;
|
||||
syslog_ip_addr.sin_port = htons(514);
|
||||
|
||||
is_file = false;
|
||||
|
||||
log_level_file = ll;
|
||||
|
||||
l_timestamp = false;
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
void setll(const log_level_t ll_screen, const log_level_t ll_file)
|
||||
|
|
3
log.h
3
log.h
|
@ -12,9 +12,10 @@ typedef enum { ll_emerg = 0, ll_alert, ll_critical, ll_error, warning, notice, i
|
|||
|
||||
log_level_t parse_ll(const std::string & str);
|
||||
void setlogfile(const char *const lf, const log_level_t ll_file, const log_level_t ll_screen, const bool l_timestamp);
|
||||
void setloghost(const char *const host, const log_level_t ll);
|
||||
bool setloghost(const char *const host, const log_level_t ll);
|
||||
void setll(const log_level_t ll_screen, const log_level_t ll_file);
|
||||
void setloguid(const int uid, const int gid);
|
||||
void send_syslog(const int ll, const std::string & what);
|
||||
void closelog();
|
||||
void dolog(const log_level_t ll, const char *fmt, ...);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue