From a9831d9cc6f4131c77fdb4814b77840015838e4f Mon Sep 17 00:00:00 2001 From: Timo Wischer Date: Mon, 29 Feb 2016 12:13:03 +0100 Subject: [PATCH] Make it possible to disable syslog --- esp-link/cgiservices.c | 7 ++++++- esp-link/main.c | 5 ++++- include/user_config.h | 9 +++++++++ serial/serbridge.c | 7 +++++++ 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/esp-link/cgiservices.c b/esp-link/cgiservices.c index 6d3704c..c42fd96 100644 --- a/esp-link/cgiservices.c +++ b/esp-link/cgiservices.c @@ -2,10 +2,13 @@ #include "cgiwifi.h" #include "cgi.h" #include "config.h" -#include "syslog.h" #include "sntp.h" #include "cgimqtt.h" +#ifdef SYSLOG +#include "syslog.h" +#endif + #ifdef CGISERVICES_DBG #define DBG(format, ...) do { os_printf(format, ## __VA_ARGS__); } while(0) #else @@ -138,6 +141,7 @@ int ICACHE_FLASH_ATTR cgiServicesInfo(HttpdConnData *connData) { int ICACHE_FLASH_ATTR cgiServicesSet(HttpdConnData *connData) { if (connData->conn == NULL) return HTTPD_CGI_DONE; // Connection aborted. Clean up. +#ifdef SYSLOG int8_t syslog = 0; syslog |= getStringArg(connData, "syslog_host", flashConfig.syslog_host, sizeof(flashConfig.syslog_host)); @@ -154,6 +158,7 @@ int ICACHE_FLASH_ATTR cgiServicesSet(HttpdConnData *connData) { if (syslog > 0) { syslog_init(flashConfig.syslog_host); } +#endif int8_t sntp = 0; sntp |= getInt8Arg(connData, "timezone_offset", &flashConfig.timezone_offset); diff --git a/esp-link/main.c b/esp-link/main.c index bfc0745..e7a65f1 100644 --- a/esp-link/main.c +++ b/esp-link/main.c @@ -29,9 +29,12 @@ #include "config.h" #include "log.h" #include "gpio.h" -#include "syslog.h" #include "cgiservices.h" +#ifdef SYSLOG +#include "syslog.h" +#endif + #define NOTICE(format, ...) do { \ LOG_NOTICE(format, ## __VA_ARGS__ ); \ os_printf(format "\n", ## __VA_ARGS__); \ diff --git a/include/user_config.h b/include/user_config.h index a939533..f0b6d3e 100644 --- a/include/user_config.h +++ b/include/user_config.h @@ -37,6 +37,15 @@ // If defined, the default hostname for DHCP will include the chip ID to make it unique #undef CHIP_IN_HOSTNAME +#ifndef SYSLOG +#define LOG_DEBUG(format, ...) do { } while(0) +#define LOG_NOTICE(format, ...) do { } while(0) +#define LOG_WARN(format, ...) do { } while(0) +#define LOG_INFO(format, ...) do { } while(0) +#define LOG_ERR(format, ...) do { } while(0) +#endif + + extern char* esp_link_version; extern uint8_t UTILS_StrToIP(const char* str, void *ip); diff --git a/serial/serbridge.c b/serial/serbridge.c index 1e82e3d..2ba1834 100644 --- a/serial/serbridge.c +++ b/serial/serbridge.c @@ -10,7 +10,10 @@ #include "console.h" #include "slip.h" #include "cmd.h" + +#ifdef SYSLOG #include "syslog.h" +#endif #define SKIP_AT_RESET @@ -405,12 +408,16 @@ serbridgeConnectCb(void *arg) #ifdef SERBR_DBG os_printf("Accept port %d, conn=%p, pool slot %d\n", conn->proto.tcp->local_port, conn, i); #endif +#ifdef SYSLOG syslog(SYSLOG_FAC_USER, SYSLOG_PRIO_NOTICE, "esp-link", "Accept port %d, conn=%p, pool slot %d\n", conn->proto.tcp->local_port, conn, i); +#endif if (i==MAX_CONN) { #ifdef SERBR_DBG os_printf("Aiee, conn pool overflow!\n"); #endif +#ifdef SYSLOG syslog(SYSLOG_FAC_USER, SYSLOG_PRIO_WARNING, "esp-link", "Aiee, conn pool overflow!\n"); +#endif espconn_disconnect(conn); return; }