upload source
[pkgs/d/drm-trusted.git] / include / drm_trusted_client_log.h
1 /*
2  *  drm-trusted-client
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Hakjoo Ko <hakjoo.ko@samsung.com>
7  *                      Mahendra Kumar Prajapat <mahendra.p@samsung.com>
8  *                      Harsha Shekar <h.shekar@samsung.com>
9  *
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  *
23  */
24
25 /**
26  * @file                drm_trusted_client_log.h
27  * @brief       DRM Trusted Client log specific file.
28  * @author      Harsha Shekar (h.shekar@samsung.com)
29  * @version     0.1
30  * @history     0.1: DRM LOG definitions.
31  */
32
33 #ifndef __DRM_TRUSTED_CLIENT_LOG_H__
34 #define __DRM_TRUSTED_CLIENT_LOG_H__
35
36 #ifdef __cplusplus
37 extern "C" {
38 #endif /*__cplusplus */
39
40 #include <sys/types.h>
41 #include <sys/stat.h>
42 #include <sys/syscall.h>
43 #include <linux/unistd.h>
44 #include <unistd.h>
45 #include <string.h>
46
47 #define drmtrustedclientgettid() (long int)syscall(__NR_gettid)
48 #define DRM_TRUSTED_CLIENT_FILENAME(X)   (strrchr((char *)(X), '/') ? (char *)(strrchr((char*)(X), '/') + 1) : ((char *)(X)))
49
50 /*
51  * Enable this flag to use internal logging mechanism
52  */
53 //#define __DRM_TRUSTED_CLIENT_USE_INTERNAL_LOGGING__
54
55 #ifdef __DRM_TRUSTED_CLIENT_USE_INTERNAL_LOGGING__
56
57 /* Use internal logging mechanism */
58 extern const char *__progname;
59
60 #define DRM_TRUSTED_CLIENT_LOG(FMT, ARG...)     do{ \
61         fprintf(stderr, "\n [EXE name=%s]:[PID=%ld]:[TID=%ld]:[%s:%s:%d]:", __progname, (long int)getpid(), drmtrustedclientgettid(), DRM_TRUSTED_CLIENT_FILENAME(__FILE__), __func__, __LINE__);       \
62         fprintf(stderr, FMT, ##ARG); \
63         fprintf(stderr,"\n"); \
64         }while(0);
65
66 #define DRM_TRUSTED_CLIENT_EXCEPTION(FMT, ARG...)       do{ \
67         fprintf(stderr, "\n [EXE name=%s]:[PID=%ld]:[TID=%ld]:[%s:%s:%d]:[DRM-ERROR-CLIENT]:", __progname, (long int)getpid(), drmtrustedclientgettid(), DRM_TRUSTED_CLIENT_FILENAME(__FILE__), __func__, __LINE__);    \
68         fprintf(stderr, FMT, ##ARG); \
69         fprintf(stderr,"\n"); \
70         }while(0);
71
72 #define DRM_TRUSTED_CLIENT_FRQ_LOG DRM_TRUSTED_CLIENT_LOG
73
74 #else   /*__DRM_TRUSTED_CLIENT_USE_INTERNAL_LOGGING__ */
75
76 /* Use DLOG logging mechanism */
77 #include "dlog.h"
78
79 /* DRM Trusted Client layer debug messages*/
80 #define TAG_DRM_TRUSTED_CLIENT  "DRM_TRUSTED_CLIENT"
81
82 /* DLOG Level
83 DEBUG  Debug message. - always compiled into application, but not logged at run time by default on release mode. on debug mode, this message will be logged at run time.
84 INFO  Information message - Normal operational messages. above of this priority will always be logged.
85 WARN  Warning messages - not an error, but indication that an error will occur if action is not taken
86 ERROR  Error message - indicate error.
87 */
88
89 /* Trusted Client layer related logs */
90 #define DRM_TRUSTED_CLIENT_LOG(FMT, ARG...)                                     SLOG(LOG_INFO,  TAG_DRM_TRUSTED_CLIENT, "[PID=%ld]:[TID=%ld]:[%s:%s:%d]:"FMT, (long int)getpid(), drmtrustedclientgettid(), DRM_TRUSTED_CLIENT_FILENAME(__FILE__), __func__, __LINE__,  ##ARG);
91 #define DRM_TRUSTED_CLIENT_FRQ_LOG(FMT, ARG...)                         SLOG(LOG_DEBUG, TAG_DRM_TRUSTED_CLIENT, "[PID=%ld]:[TID=%ld]:[%s:%s:%d]:"FMT, (long int)getpid(), drmtrustedclientgettid(), DRM_TRUSTED_CLIENT_FILENAME(__FILE__), __func__, __LINE__, ##ARG);
92 #define DRM_TRUSTED_CLIENT_EXCEPTION(FMT, ARG...)                       SLOG(LOG_ERROR, TAG_DRM_TRUSTED_CLIENT, "[PID=%ld]:[TID=%ld]:[%s:%s:%d]:[DRM-ERROR-CLIENT]"FMT"\n", (long int)getpid(), drmtrustedclientgettid(), DRM_TRUSTED_CLIENT_FILENAME(__FILE__), __func__, __LINE__, ##ARG);
93
94 #endif  /* __DRM_TRUSTED_CLIENT_USE_INTERNAL_LOGGING__ */
95
96 #ifdef __cplusplus
97 }
98 #endif /* __cplusplus */
99
100 #endif  /* __DRM_TRUSTED_CLIENT_LOG_H__*/