renamed short variable name
This commit is contained in:
parent
42c4a84dde
commit
2432667c1d
1 changed files with 15 additions and 15 deletions
30
log.cpp
30
log.cpp
|
@ -25,7 +25,7 @@ static sockaddr_in syslog_ip_addr = { };
|
||||||
static bool is_file = true;
|
static bool is_file = true;
|
||||||
log_level_t log_level_file = warning;
|
log_level_t log_level_file = warning;
|
||||||
log_level_t log_level_screen = warning;
|
log_level_t log_level_screen = warning;
|
||||||
FILE *lfh = nullptr;
|
static FILE *log_fh = nullptr;
|
||||||
static int lf_uid = -1;
|
static int lf_uid = -1;
|
||||||
static int lf_gid = -1;
|
static int lf_gid = -1;
|
||||||
static bool l_timestamp = true;
|
static bool l_timestamp = true;
|
||||||
|
@ -41,8 +41,8 @@ int gettid()
|
||||||
|
|
||||||
void setlogfile(const char *const lf, const log_level_t ll_file, const log_level_t ll_screen, const bool timestamp)
|
void setlogfile(const char *const lf, const log_level_t ll_file, const log_level_t ll_screen, const bool timestamp)
|
||||||
{
|
{
|
||||||
if (lfh)
|
if (log_fh)
|
||||||
fclose(lfh);
|
fclose(log_fh);
|
||||||
|
|
||||||
free((void *)logfile);
|
free((void *)logfile);
|
||||||
|
|
||||||
|
@ -98,26 +98,26 @@ void send_syslog(const int ll, const std::string & what)
|
||||||
|
|
||||||
void closelog()
|
void closelog()
|
||||||
{
|
{
|
||||||
if (lfh) {
|
if (log_fh) {
|
||||||
fclose(lfh);
|
fclose(log_fh);
|
||||||
|
|
||||||
lfh = nullptr;
|
log_fh = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dolog(const log_level_t ll, const char *fmt, ...)
|
void dolog(const log_level_t ll, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
#if !defined(BUILD_FOR_RP2040)
|
#if !defined(BUILD_FOR_RP2040)
|
||||||
if (!lfh && logfile != nullptr) {
|
if (!log_fh && logfile != nullptr) {
|
||||||
#if !defined(ESP32)
|
#if !defined(ESP32)
|
||||||
lfh = fopen(logfile, "a+");
|
log_fh = fopen(logfile, "a+");
|
||||||
if (!lfh)
|
if (!log_fh)
|
||||||
error_exit(true, "Cannot access log-file %s", logfile);
|
error_exit(true, "Cannot access log-file %s", logfile);
|
||||||
#if !defined(_WIN32)
|
#if !defined(_WIN32)
|
||||||
if (lf_uid != -1 && fchown(fileno(lfh), lf_uid, lf_gid) == -1)
|
if (lf_uid != -1 && fchown(fileno(log_fh), lf_uid, lf_gid) == -1)
|
||||||
error_exit(true, "Cannot change logfile (%s) ownership", logfile);
|
error_exit(true, "Cannot change logfile (%s) ownership", logfile);
|
||||||
|
|
||||||
if (fcntl(fileno(lfh), F_SETFD, FD_CLOEXEC) == -1)
|
if (fcntl(fileno(log_fh), F_SETFD, FD_CLOEXEC) == -1)
|
||||||
error_exit(true, "fcntl(FD_CLOEXEC) failed");
|
error_exit(true, "fcntl(FD_CLOEXEC) failed");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -158,8 +158,8 @@ void dolog(const log_level_t ll, const char *fmt, ...)
|
||||||
if (ll <= log_level_file && is_file == false)
|
if (ll <= log_level_file && is_file == false)
|
||||||
send_syslog(ll, log_buffer);
|
send_syslog(ll, log_buffer);
|
||||||
#if !defined(ESP32)
|
#if !defined(ESP32)
|
||||||
if (ll <= log_level_file && lfh != nullptr)
|
if (ll <= log_level_file && log_fh != nullptr)
|
||||||
fprintf(lfh, "%s%s\n", ts_str, log_buffer);
|
fprintf(log_fh, "%s%s\n", ts_str, log_buffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ll <= log_level_screen)
|
if (ll <= log_level_screen)
|
||||||
|
@ -169,8 +169,8 @@ void dolog(const log_level_t ll, const char *fmt, ...)
|
||||||
if (ll <= log_level_file && is_file == false)
|
if (ll <= log_level_file && is_file == false)
|
||||||
send_syslog(ll, log_buffer);
|
send_syslog(ll, log_buffer);
|
||||||
#if !defined(ESP32)
|
#if !defined(ESP32)
|
||||||
if (ll <= log_level_file && lfh != nullptr)
|
if (ll <= log_level_file && log_fh != nullptr)
|
||||||
fprintf(lfh, "%s\n", log_buffer);
|
fprintf(log_fh, "%s\n", log_buffer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (ll <= log_level_screen)
|
if (ll <= log_level_screen)
|
||||||
|
|
Loading…
Add table
Reference in a new issue