Introduce rotation parameter defaults for both server and util 10/143410/7
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Thu, 10 Aug 2017 13:03:00 +0000 (15:03 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Fri, 11 Aug 2017 10:54:19 +0000 (12:54 +0200)
 * file size (-r): 1 MB
 * file count (-n): 3

Change-Id: I8be4ad5dcab0a04b1ba92b6f7072e8b4c2ba0783
Signed-off-by: Michal Bloch <m.bloch@samsung.com>
Signed-off-by: Karol Lewandowski <k.lewandowsk@samsung.com>
include/log_file.h
src/logutil/logutil_doc.h
src/shared/log_file.c

index 0157bc9..dca69d3 100644 (file)
 
 #include <logprint.h>
 
+/* Logfile rotation */
+#define DEFAULT_ROTATE_SIZE_KB 1024
+#define DEFAULT_ROTATE_NUM_FILES 3
+
 #define BtoKiB(x)      ((x) >> 10)
 
 struct log_file;
index 1081eca..08c9794 100644 (file)
@@ -43,8 +43,8 @@ static void show_help(const char *cmd)
                "  -s                Set default filter to silent.\n"
                "                    Like specifying filterspec '*:s'\n"
                "  -f <filename>     Log to file. Default to stdout\n"
-               "  -r [<kbytes>]     Rotate log every kbytes. Requires -f and -n > 0, else no rotation\n"
-               "  -n <count>        Sets max number of rotated logs to <count>. Requires -f and -r > 0, else no rotation\n"
+               "  -r [<kbytes>]     Rotate log every kB (defaults to: " STRINGIFY(DEFAULT_ROTATE_SIZE_KB) "kB). Requires -f and -n > 0, else no rotation\n"
+               "  -n <count>        Sets max number of rotated logs to <count> (defaults to: " STRINGIFY(DEFAULT_ROTATE_NUM_FILES) "). Requires -f and -r > 0, else no rotation\n"
                "  -v <format>       Sets the log print format, where <format> is one of:\n"
                "                    brief(by default) process tag thread raw time threadtime kerneltime long recv_realtime rwtime\n"
                "  -c                clear (flush) the entire log and exit without printing logs\n"
@@ -68,7 +68,6 @@ static void show_help(const char *cmd)
                "  F    Fatal\n"
                "  S    Silent (supress all output)\n"
                "\n'*' means '*:D' and <tag> by itself means <tag>:V\n"
-               "If no filterspec is found, filter defaults to '*:I'\n\n"
-
-       , cmd);
+               "If no filterspec is found, filter defaults to '*:I'\n\n",
+               cmd);
 }
index 51b3c96..f0bbf83 100644 (file)
@@ -40,6 +40,8 @@ int logfile_init(struct log_file *l_file)
        memset(l_file, 0, sizeof(struct log_file));
 
        l_file->fd = -1;
+       l_file->rotate_size_kbytes = DEFAULT_ROTATE_SIZE_KB;
+       l_file->max_rotated = DEFAULT_ROTATE_NUM_FILES;
        l_file->format = log_format_new();
 
        return l_file->format != NULL ? 0 : -1;