From e02042cadeda6ff2dc32ba2aecd3533c4e96c199 Mon Sep 17 00:00:00 2001 From: Fufu Fang Date: Tue, 31 Aug 2021 11:50:59 +0100 Subject: [PATCH] improved logging --- src/cache.c | 2 +- src/fuse_local.c | 4 +++- src/link.c | 4 ++-- src/log.c | 13 ++++++------- src/log.h | 2 +- 5 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/cache.c b/src/cache.c index fbdf92c..a2c6255 100644 --- a/src/cache.c +++ b/src/cache.c @@ -95,7 +95,7 @@ void CacheSystem_init(const char *path, int url_supplied) path = CacheSystem_calc_dir(path); } - lprintf(debug, "directory: %s\n", path); + lprintf(debug, "%s\n", path); META_DIR = path_append(path, "meta/"); DATA_DIR = path_append(path, "data/"); diff --git a/src/fuse_local.c b/src/fuse_local.c index 0698390..eb68b3c 100644 --- a/src/fuse_local.c +++ b/src/fuse_local.c @@ -1,6 +1,7 @@ #include "fuse_local.h" #include "cache.h" +#include "log.h" /* * must be included before including @@ -21,6 +22,7 @@ static void *fs_init(struct fuse_conn_info *conn) /** \brief release an opened file */ static int fs_release(const char *path, struct fuse_file_info *fi) { + lprintf(info, "%s\n", path); (void) path; if (CACHE_SYSTEM_INIT) { Cache_close((Cache *) fi->fh); @@ -88,6 +90,7 @@ fs_read(const char *path, char *buf, size_t size, off_t offset, /** \brief open a file indicated by the path */ static int fs_open(const char *path, struct fuse_file_info *fi) { + lprintf(info, "%s\n", path); Link *link = path_to_Link(path); if (!link) { return -ENOENT; @@ -133,7 +136,6 @@ fs_readdir(const char *path, void *buf, fuse_fill_dir_t dir_add, { (void) offset; (void) fi; - LinkTable *linktbl; if (!strcmp(path, "/")) { diff --git a/src/link.c b/src/link.c index f7f013b..3eec8fe 100644 --- a/src/link.c +++ b/src/link.c @@ -353,7 +353,7 @@ static void LinkTable_uninitialised_fill(LinkTable * linktbl) while (u); if (CONFIG.log_type & debug) { erase_string(stderr, STATUS_LEN, s); - fprintf(stderr, "Done!\n"); + fprintf(stderr, "... Done!\n"); } } @@ -424,7 +424,7 @@ void LinkTable_print(LinkTable * linktbl) } } lprintf(info, "--------------------------------------------\n"); - lprintf(info, "LinkTable_print(): Invalid link count: %d\n", j); + lprintf(info, " Invalid link count: %d\n", j); lprintf(info, "--------------------------------------------\n"); } } diff --git a/src/log.c b/src/log.c index 83faf29..b76eab1 100644 --- a/src/log.c +++ b/src/log.c @@ -24,28 +24,27 @@ log_printf(LogType type, const char *file, const char *func, int line, if (type & CONFIG.log_type) { switch (type) { case fatal: - fprintf(out, "Fatal: "); + fprintf(out, "Fatal:"); break; case error: - fprintf(out, "Error: "); + fprintf(out, "Error:"); break; case warning: - fprintf(out, "Warning: "); + fprintf(out, "Warning:"); break; case info: - out = stderr; goto print_actual_message; - break; default: - fprintf(out, "Debug (%x):", type); + fprintf(out, "Debug(%x):", type); break; } - fprintf(out, "(%s:%s:%d): ", file, func, line); + fprintf(out, "%s:%d:", file, line); print_actual_message: { } + fprintf(out, "%s: ", func); va_list args; va_start(args, format); vfprintf(out, format, args); diff --git a/src/log.h b/src/log.h index e907b52..4b1f77b 100644 --- a/src/log.h +++ b/src/log.h @@ -18,7 +18,7 @@ typedef enum { /** * \brief The default log level */ -#define DEFAULT_LOG_LEVEL fatal | error | warning | info | debug +#define DEFAULT_LOG_LEVEL fatal | error | warning | info /** * \brief Get the log level from the environment.