500f405b7c8915bb0dd9c0be1518b36b57aa108c
[framework/web/wrt-installer.git] / src_wearable / commons / installer_log.h
1 /*
2  * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.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
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 /**
17  * @file       installer_log.h
18  * @author     Sungsu Kim(sung-su.kim@samsung.com)
19  * @version    0.1
20  * @brief
21  */
22
23 #ifndef INSTALLER_LOG_H
24 #define INSTALLER_LOG_H
25
26 #include <unistd.h>
27 #include <stdio.h>
28
29 #include <dpl/log/secure_log.h>
30
31 #ifdef WRT_INSTALLER_LOG
32
33 #undef COLOR_WARNING
34 #define COLOR_WARNING "\e[0m"
35 #undef COLOR_TAG
36 #define COLOR_TAG "\e[0m"
37
38 #endif
39
40 // For FOTA debuging
41 #if 0
42 #define PKGMGR_FOTA_PATH                "/opt/share/packages/.recovery/fota/"
43 #define FOTA_RESULT_FILE                PKGMGR_FOTA_PATH"result.txt"
44
45 #define _FLOG(prio, fmt, arg...) do { \
46         int __fd = 0;\
47         FILE* __file = NULL;\
48         __file = fopen(FOTA_RESULT_FILE, "a");\
49         if (__file == NULL) break;\
50         fprintf(__file, "[PKG_FOTA] [wrt-installer] [%s] [%s:%d] "fmt"\n", prio, __FUNCTION__, __LINE__, ##arg); \
51         fflush(__file);\
52         __fd = fileno(__file);\
53         fsync(__fd);\
54         fclose(__file);\
55 } while (0)
56
57 #undef _D
58 #define _D(fmt, arg ...) _FLOG("D", fmt, ##arg)
59
60 #undef _W
61 #define _W(fmt, arg ...) _FLOG("W", fmt, ##arg)
62
63 #undef _E
64 #define _E(fmt, arg ...) _FLOG("E", fmt, ##arg)
65 #endif
66
67
68 #endif // INSTALLER_LOG_H
69