mirror of
https://github.com/servalproject/serval-dna.git
synced 2024-12-18 20:57:56 +00:00
New config option: 'debug.config'
Logs some information about configuration file loading and re-loading
This commit is contained in:
parent
d022bbdf27
commit
5d9e3f1287
20
conf.c
20
conf.c
@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include <stdio.h>
|
||||
#include <sys/stat.h>
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include "conf.h"
|
||||
#include "log.h"
|
||||
#include "str.h"
|
||||
@ -73,9 +74,18 @@ static int cmp_meta(const struct file_meta *a, const struct file_meta *b)
|
||||
|
||||
static int reload(const char *path, int *resultp)
|
||||
{
|
||||
if (config.debug.config)
|
||||
DEBUGF("path=%s", alloca_str_toprint(path));
|
||||
struct file_meta meta;
|
||||
if (get_meta(conffile_path(), &meta) == -1)
|
||||
return -1;
|
||||
if (config.debug.config) {
|
||||
struct tm tm;
|
||||
(void)localtime_r(&meta.mtime, &tm);
|
||||
DEBUGF("meta.mtime=%s meta.size=%ld", alloca_strftime("%Y/%m/%d %H:%M:%S", &tm), (long)meta.size);
|
||||
(void)localtime_r(&conffile_meta.mtime, &tm);
|
||||
DEBUGF("conffile_meta.mtime=%s conffile_meta.size=%ld", alloca_strftime("%Y/%m/%d %H:%M:%S", &tm), (long)conffile_meta.size);
|
||||
}
|
||||
if (cmp_meta(&meta, &conffile_meta) == 0)
|
||||
return 0;
|
||||
if (conffile_meta.mtime != -1 && serverMode)
|
||||
@ -116,6 +126,11 @@ static int reload(const char *path, int *resultp)
|
||||
INFOF("config file %s successfully read %ld bytes", path, (long) meta.size);
|
||||
}
|
||||
conffile_meta = meta;
|
||||
if (config.debug.config) {
|
||||
struct tm tm;
|
||||
(void)localtime_r(&conffile_meta.mtime, &tm);
|
||||
DEBUGF("conffile_meta.mtime=%s conffile_meta.size=%ld", alloca_strftime("%Y/%m/%d %H:%M:%S", &tm), (long)conffile_meta.size);
|
||||
}
|
||||
struct cf_om_node *new_root = NULL;
|
||||
*resultp = cf_om_parse(path, buf, meta.size, &new_root);
|
||||
free(buf);
|
||||
@ -165,6 +180,11 @@ int cf_om_save()
|
||||
return -1;
|
||||
INFOF("successfully wrote %s", path);
|
||||
conffile_meta = meta;
|
||||
if (config.debug.config) {
|
||||
struct tm tm;
|
||||
(void)localtime_r(&conffile_meta.mtime, &tm);
|
||||
DEBUGF("conffile_meta.mtime=%s conffile_meta.size=%ld", alloca_strftime("%Y/%m/%d %H:%M:%S", &tm), (long)conffile_meta.size);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -229,6 +229,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
STRUCT(debug)
|
||||
ATOM(bool_t, verbose, 0, boolean,, "")
|
||||
ATOM(bool_t, ack, 0, boolean,, "")
|
||||
ATOM(bool_t, config, 0, boolean,, "")
|
||||
ATOM(bool_t, dnaresponses, 0, boolean,, "")
|
||||
ATOM(bool_t, dnahelper, 0, boolean,, "")
|
||||
ATOM(bool_t, queues, 0, boolean,, "")
|
||||
|
@ -148,6 +148,7 @@ strbuf strbuf_append_socket_address(strbuf sb, const struct socket_address *addr
|
||||
*/
|
||||
struct tm;
|
||||
strbuf strbuf_append_strftime(strbuf sb, const char *format, const struct tm *tm);
|
||||
#define alloca_strftime(fmt,tm) strbuf_str(strbuf_append_strftime(strbuf_alloca(40), (fmt), (tm)))
|
||||
|
||||
/* Append a representation of a struct iovec[] array.
|
||||
* @author Andrew Bettison <andrew@servalproject.com>
|
||||
|
Loading…
Reference in New Issue
Block a user