2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
27 #define LOGFILE DATADIR"/quickpanel.log"
30 #define MAXSIZE (1 << 17)
34 void debug_printf(const char *msg, ...)
46 localtime_r(&ctime, &ts);
48 snprintf(buf, 64, "[%04d/%02d/%02d %02d:%02d:%02d] ",
49 ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday,
50 ts.tm_hour, ts.tm_min, ts.tm_sec);
53 va_start(arg_list, msg);
55 fd = open(LOGFILE, O_WRONLY | O_CREAT | O_APPEND,
56 S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
58 fprintf(stderr, msg, arg_list);
62 status = fstat(fd, &buffer);
63 if (!status && (buffer.st_size > MAXSIZE)) {
67 len = vsnprintf(&buf[len], 511, msg, arg_list);
68 /* fix for flawfinder warnings: check string length */
73 write(fd, buf, strlen(buf));