2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (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://floralicense.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.
28 #include "lockd-debug.h"
31 #define MAXFILELEN 1048576
32 #define LOGFILE "/tmp/starter.log"
34 void lockd_log_t(char *fmt, ...)
38 char buf[LINEMAX] = { 0, };
39 char debugString[LINEMAX] = { 0, };
42 vsnprintf(buf, sizeof(buf), fmt, ap);
46 time_t current_time = 0;
47 bzero((char *)&debugString, LINEMAX);
49 gmtime_r(¤t_time, &local_t);
50 int len = snprintf(debugString, sizeof(debugString),
51 "[%d-%02d-%02d, %02d:%02d:%02d]: ",
52 local_t.tm_year + 1900, local_t.tm_mon + 1,
53 local_t.tm_mday, local_t.tm_hour, local_t.tm_min,
58 debugString[len] = '\0';
60 len = g_strlcat(debugString, buf, LINEMAX);
64 debugString[len] = '\n';
66 if ((fd = fopen(LOGFILE, "at+")) == NULL) {
67 LOCKD_DBG("File fopen fail for writing Pwlock information");
70 if (fwrite(debugString, strlen(debugString), 1, fd) < 1) {
72 ("File fwrite fail for writing Pwlock information");
74 if ((pid = fork()) < 0) {
75 } else if (pid == 0) {
76 execl("/bin/rm", "rm", "-f", LOGFILE,
80 fseek(fd, 0l, SEEK_END);
82 if (fileLen > MAXFILELEN) {
84 if ((pid = fork()) < 0) {
86 } else if (pid == 0) {
87 execl("/bin/rm", "rm", "-f", LOGFILE,