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.
26 #include "lockd-debug.h"
29 #define MAXFILELEN 1048576
30 #define LOGFILE "/tmp/starter.log"
32 void lockd_log_t(char *fmt, ...)
36 char buf[LINEMAX] = { 0, };
37 char debugString[LINEMAX] = { 0, };
40 vsnprintf(buf, sizeof(buf), fmt, ap);
44 time_t current_time = 0;
45 bzero((char *)&debugString, LINEMAX);
47 gmtime_r(¤t_time, &local_t);
48 int len = snprintf(debugString, sizeof(debugString),
49 "[%d-%02d-%02d, %02d:%02d:%02d]: ",
50 local_t.tm_year + 1900, local_t.tm_mon + 1,
51 local_t.tm_mday, local_t.tm_hour, local_t.tm_min,
56 debugString[len] = '\0';
58 len = g_strlcat(debugString, buf, LINEMAX);
62 debugString[len] = '\n';
64 if ((fd = fopen(LOGFILE, "at+")) == NULL) {
65 LOCKD_DBG("File fopen fail for writing Pwlock information");
68 if (fwrite(debugString, strlen(debugString), 1, fd) < 1) {
70 ("File fwrite fail for writing Pwlock information");
72 if ((pid = fork()) < 0) {
73 } else if (pid == 0) {
74 execl("/bin/rm", "rm", "-f", LOGFILE,
78 fseek(fd, 0l, SEEK_END);
80 if (fileLen > MAXFILELEN) {
82 if ((pid = fork()) < 0) {
84 } else if (pid == 0) {
85 execl("/bin/rm", "rm", "-f", LOGFILE,