X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=logutil.c;h=cb211dae7427f22482bd0792924455cdeb616132;hb=310597132825b77a3114ec60a39bff39364c4ab6;hp=d9d369f47f4e34bac60abd26f6264992c71dcd98;hpb=4dc36c99cdfdad3463b94d2bd943208c17220db9;p=framework%2Fsystem%2Fdlog.git diff --git a/logutil.c b/logutil.c index d9d369f..cb211da 100755 --- a/logutil.c +++ b/logutil.c @@ -97,7 +97,7 @@ static void enqueue(struct log_device_t* device, struct queued_entry_t* entry) static int open_logfile (const char *pathname) { - return open(pathname, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR); + return open(pathname, O_WRONLY | O_APPEND | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH); } static void rotate_logs() @@ -356,23 +356,23 @@ static int get_log_readable_size(int logfd) static void setup_output() { - if (g_output_filename == NULL) { - g_outfd = STDOUT_FILENO; - - } else { - struct stat statbuf; + if (g_output_filename == NULL) { + g_outfd = STDOUT_FILENO; - g_outfd = open_logfile (g_output_filename); - - if (g_outfd < 0) { - perror ("couldn't open output file"); - exit(-1); - } + } else { + struct stat statbuf; - fstat(g_outfd, &statbuf); + g_outfd = open_logfile (g_output_filename); - g_out_byte_count = statbuf.st_size; - } + if (g_outfd < 0) { + perror ("couldn't open output file"); + exit(-1); + } + if (fstat(g_outfd, &statbuf) == -1) + g_out_byte_count = 0; + else + g_out_byte_count = statbuf.st_size; + } } static int set_log_format(const char * formatString) @@ -402,11 +402,11 @@ static void show_help(const char *cmd) " -r [] Rotate log every kbytes. (16 if unspecified). Requires -f\n" " -n Sets max number of rotated logs to , default 4\n" " -v Sets the log print format, where is one of:\n\n" - " brief process tag thread raw time threadtime long\n\n" - " -c clear (flush) the entire log and exit\n" + " brief(by default) process tag thread raw time threadtime long\n\n" + " -c clear (flush) the entire log and exit, conflicts with '-g'\n" " -d dump the log and then exit (don't block)\n" " -t print only the most recent lines (implies -d)\n" - " -g get the size of the log's ring buffer and exit\n" + " -g get the size of the log's ring buffer and exit, conflicts with '-c'\n" " -b request alternate ring buffer\n" " ('main' (default), 'radio', 'system')"); @@ -422,11 +422,7 @@ static void show_help(const char *cmd) " F Fatal\n" " S Silent (supress all output)\n" "\n'*' means '*:D' and by itself means :V\n" - "If no filterspec is found, filter defaults to '*:I'\n" - "\nIf not specified with -v, format is set defaults to \"brief\"\n\n"); - - - + "If no filterspec is found, filter defaults to '*:I'\n\n"); } @@ -581,7 +577,7 @@ int main(int argc, char **argv) case 'b': { char *buf; - if (asprintf(&buf, LOG_FILE_DIR "/%s", optarg) == -1) { + if (asprintf(&buf, LOG_FILE_DIR "%s", optarg) == -1) { asprintf(stderr,"Can't malloc LOG_FILE_DIR\n"); exit(-1); } @@ -652,6 +648,12 @@ int main(int argc, char **argv) } } + /* get log size conflicts with write mode */ + if (getLogSize && mode != O_RDONLY) { + show_help(argv[0]); + exit(-1); + } + if (!devices) { devices = log_devices_new("/dev/"LOGGER_LOG_MAIN); if (devices == NULL) {