improved logging

This commit is contained in:
Fufu Fang 2021-08-31 11:50:59 +01:00
parent 45d8cb8136
commit e02042cade
No known key found for this signature in database
GPG Key ID: 0F6BB5EF6F8BB729
5 changed files with 13 additions and 12 deletions

View File

@ -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/");

View File

@ -1,6 +1,7 @@
#include "fuse_local.h"
#include "cache.h"
#include "log.h"
/*
* must be included before including <fuse.h>
@ -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, "/")) {

View File

@ -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");
}
}

View File

@ -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);

View File

@ -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.