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