diff --git a/debugger.cpp b/debugger.cpp index 9d2244b..9b5fcb9 100644 --- a/debugger.cpp +++ b/debugger.cpp @@ -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", diff --git a/log.cpp b/log.cpp index d250081..df44581 100644 --- a/log.cpp +++ b/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) diff --git a/log.h b/log.h index 50b6ce5..668cf33 100644 --- a/log.h +++ b/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, ...);