RDK Documentation (Open Sourced RDK Components)
Debug.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 
20 #ifndef _DIAG_DEBUG_H_
21 #define _DIAG_DEBUG_H_
22 
23 #include <stdint.h>
24 #include <errno.h>
25 #include <stdlib.h>
26 #include <time.h>
27 
28 //#define ENABLE_DIAG_DEBUG
29 
30 
31 /* Time stamp information */
32 #define __TIMESTAMP() do { /*YYMMDD-HH:MM:SS:usec*/ \
33  struct tm __tm; \
34  struct timeval __tv; \
35  gettimeofday(&__tv, NULL); \
36  localtime_r(&__tv.tv_sec, &__tm); \
37  printf("[TRMMgr=%ld %02d%02d%02d-%02d:%02d:%02d:%06d ", \
38  syscall(SYS_gettid), \
39  __tm.tm_year+1900-2000, \
40  __tm.tm_mon+1, \
41  __tm.tm_mday, \
42  __tm.tm_hour, \
43  __tm.tm_min, \
44  __tm.tm_sec, \
45  (int)__tv.tv_usec); \
46 } while(0)
47 
48 
49 
50 #define DIAG_WARN( m ) __TIMESTAMP(); printf m
51 #ifdef ENABLE_DIAG_DEBUG
52  #define DIAG_TRACE( m ) __TIMESTAMP(); printf m
53  #define DIAG_DEBUG( m ) __TIMESTAMP(); printf m
54 #else
55  #define DIAG_TRACE( m )
56  #define DIAG_DEBUG( m )
57 #endif
58 
59 
60 
61 
62 #endif
63