Home | History | Annotate | Download | only in hdr
      1 /*
      2  * Copyright (C) 2014 The Android Open Source Project
      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 #ifndef XPL_LOGGER_H
     18 #define XPL_LOGGER_H
     19 
     20 /************** HEADER FILE INCLUDES *****************************************/
     21 
     22 #include "xpl_Port.h"
     23 
     24 #ifdef __cplusplus
     25 extern "C" {
     26 #endif
     27 
     28 /************** CONSTANTS ****************************************************/
     29 
     30 #define MAX_LOG_STRING_SIZE   255
     31 
     32 #define XPL_LOG_NOLOGS        0
     33 #define XPL_LOG_DEBUG         1
     34 #define XPL_LOG_WARN          2
     35 #define XPL_LOG_ERROR         3
     36 #define XPL_LOG_ALL           4
     37 
     38 // DM: for each XPL_LOG_Startup call there must be a corresponding XPL_LOG_Shutdown call
     39 void XPL_LOG_Startup();
     40 void XPL_LOG_Shutdown();
     41 
     42 #if defined(PLATFORM_X86) || defined(EZX_PRODUCT_SCMA11REF)
     43 
     44 #if defined(PLATFORM_ANDROID)
     45   #define LOG_TAG "libdmengine"
     46   #include <utils/Log.h>
     47 
     48   #ifndef LOGD
     49   #define LOGD(args...) ALOGD(args)
     50   #endif
     51 
     52   #ifndef LOGE
     53   #define LOGE(args...) ALOGE(args)
     54   #endif
     55 
     56   #ifndef LOGI
     57   #define LOGI(args...) ALOGI(args)
     58   #endif
     59 
     60   #ifndef LOGV
     61   #define LOGV(args...) ALOGV(args)
     62   #endif
     63 
     64   #ifndef LOGW
     65   #define LOGW(args...) ALOGW(args)
     66   #endif
     67 
     68   #define XPL_LOG_Error(logPortId, format, args...) \
     69     LOGE(format, ##args )
     70 
     71   #define XPL_LOG_Warn(logPortId,  format, args...) \
     72     LOGW(format, ##args )
     73 
     74   #define XPL_LOG_Debug(logPortId, format, args...) \
     75     LOGD(format, ##args )
     76 
     77   #define XPL_LOG_Enter(logPortId, format, args...) \
     78     LOGD(format, ##args )
     79 
     80   #define XPL_LOG_Leave(logPortId, format, args...) \
     81     LOGD(format, ##args )
     82 
     83   #define XPL_LOG_Startup()
     84   #define XPL_LOG_Shutdown()
     85 
     86   // define XPL_LOG_LEVEL in makefile; don't define it here.
     87 //  #define XPL_LOG_LEVEL XPL_LOG_ALL
     88 
     89   // DM: use DM log if building standalone DM engine on Redhat linux machine
     90 #elif ( XPL_LOG_LEVEL == XPL_LOG_DEBUG ) || ( XPL_LOG_LEVEL == XPL_LOG_WARN ) || ( XPL_LOG_LEVEL == XPL_LOG_ERROR ) || ( XPL_LOG_LEVEL == XPL_LOG_ALL )
     91     void XPL_LOG_Error(XPL_LOGS_PORT_T logPort, CPCHAR format, ...);
     92     void XPL_LOG_Warn(XPL_LOGS_PORT_T  logPort, CPCHAR format, ...);
     93     void XPL_LOG_Debug(XPL_LOGS_PORT_T logPort, CPCHAR format, ...);
     94     void XPL_LOG_Enter(XPL_LOGS_PORT_T logPort, CPCHAR format, ...);
     95     void XPL_LOG_Leave(XPL_LOGS_PORT_T logPort, CPCHAR format, ...);
     96 #endif
     97 
     98 #else
     99   // DM: use LJ system log if this is a LJ phone build
    100   #include <libaplog.h>
    101 
    102     struct aplog_port_struct* XPL_GetPortPtr( XPL_LOGS_PORT_T logPort );
    103 
    104   #define XPL_LOG_Error(logPortId, format, args...) \
    105     aplog_port_err_fileline( XPL_GetPortPtr( logPortId ), format, ##args )
    106 
    107   #define XPL_LOG_Warn(logPortId,  format, args...) \
    108     aplog_port_warning_fileline( XPL_GetPortPtr( logPortId ), format, ##args )
    109 
    110   #define XPL_LOG_Debug(logPortId, format, args...) \
    111     aplog_port_debug_fileline( XPL_GetPortPtr( logPortId ), format, ##args )
    112 
    113   #define XPL_LOG_Enter(logPortId, format, args...) \
    114     aplog_port_func_enter_print( XPL_GetPortPtr( logPortId ), format, ##args )
    115 
    116   #define XPL_LOG_Leave(logPortId, format, args...) \
    117     aplog_port_func_exit_print( XPL_GetPortPtr( logPortId ), format, ##args )
    118 
    119   #define XPL_LOG_LEVEL XPL_LOG_ALL
    120 #endif
    121 
    122 #if ( XPL_LOG_LEVEL == XPL_LOG_DEBUG ) || ( XPL_LOG_LEVEL == XPL_LOG_WARN ) || ( XPL_LOG_LEVEL == XPL_LOG_ERROR ) || ( XPL_LOG_LEVEL == XPL_LOG_ALL )
    123   #define XPL_LOG_DM_API_Error2( args... )   XPL_LOG_Error(XPL_LOG_PORT_DM_API,   args)
    124   #define XPL_LOG_DM_PLG_Error2( args... )   XPL_LOG_Error(XPL_LOG_PORT_DM_PLG,   args)
    125   #define XPL_LOG_DM_TMN_Error2( args... )   XPL_LOG_Error(XPL_LOG_PORT_DM_TMN,   args)
    126   #define XPL_LOG_DM_SESS_Error2( args... )  XPL_LOG_Error(XPL_LOG_PORT_DM_SESS,  args)
    127   #define XPL_LOG_DM_CONN_Error2( args... )  XPL_LOG_Error(XPL_LOG_PORT_DM_CONN,  args)
    128   #define XPL_LOG_DM_XPL_Error2( args... )   XPL_LOG_Error(XPL_LOG_PORT_DM_XPL,   args)
    129   #define XPL_LOG_DM_CP_Error2( args... )    XPL_LOG_Error(XPL_LOG_PORT_DM_CP,    args)
    130 
    131   #define XPL_LOG_DM_API_Error( args... )    XPL_LOG_DM_API_Error2 args
    132   #define XPL_LOG_DM_PLG_Error( args... )    XPL_LOG_DM_PLG_Error2 args
    133   #define XPL_LOG_DM_TMN_Error( args... )    XPL_LOG_DM_TMN_Error2 args
    134   #define XPL_LOG_DM_SESS_Error( args... )   XPL_LOG_DM_SESS_Error2 args
    135   #define XPL_LOG_DM_CONN_Error( args... )   XPL_LOG_DM_CONN_Error2 args
    136   #define XPL_LOG_DM_XPL_Error( args... )    XPL_LOG_DM_XPL_Error2 args
    137   #define XPL_LOG_DM_CP_Error( args... )     XPL_LOG_DM_CP_Error2 args
    138 #else
    139   #define XPL_LOG_DM_API_Error( args... )
    140   #define XPL_LOG_DM_PLG_Error( args... )
    141   #define XPL_LOG_DM_TMN_Error( args... )
    142   #define XPL_LOG_DM_SESS_Error( args... )
    143   #define XPL_LOG_DM_CONN_Error( args... )
    144   #define XPL_LOG_DM_XPL_Error( args... )
    145   #define XPL_LOG_DM_CP_Error( args... )
    146 #endif
    147 
    148 #if ( XPL_LOG_LEVEL == XPL_LOG_DEBUG ) || ( XPL_LOG_LEVEL == XPL_LOG_WARN ) || ( XPL_LOG_LEVEL == XPL_LOG_ALL )
    149   #define XPL_LOG_DM_API_Warn2( args... )  XPL_LOG_Warn(XPL_LOG_PORT_DM_API,   args)
    150   #define XPL_LOG_DM_PLG_Warn2( args... )  XPL_LOG_Warn(XPL_LOG_PORT_DM_PLG,   args)
    151   #define XPL_LOG_DM_TMN_Warn2( args... )  XPL_LOG_Warn(XPL_LOG_PORT_DM_TMN,   args)
    152   #define XPL_LOG_DM_SESS_Warn2( args... ) XPL_LOG_Warn(XPL_LOG_PORT_DM_SESS,  args)
    153   #define XPL_LOG_DM_CONN_Warn2( args... ) XPL_LOG_Warn(XPL_LOG_PORT_DM_CONN,  args)
    154   #define XPL_LOG_DM_XPL_Warn2( args... )  XPL_LOG_Warn(XPL_LOG_PORT_DM_XPL,   args)
    155   #define XPL_LOG_DM_CP_Warn2( args... )   XPL_LOG_Warn(XPL_LOG_PORT_DM_CP,    args)
    156 
    157   #define XPL_LOG_DM_API_Warn( args... )   XPL_LOG_DM_API_Warn2 args
    158   #define XPL_LOG_DM_PLG_Warn( args... )   XPL_LOG_DM_PLG_Warn2 args
    159   #define XPL_LOG_DM_TMN_Warn( args... )   XPL_LOG_DM_TMN_Warn2 args
    160   #define XPL_LOG_DM_SESS_Warn( args... )  XPL_LOG_DM_SESS_Warn2 args
    161   #define XPL_LOG_DM_CONN_Warn( args... )  XPL_LOG_DM_CONN_Warn2 args
    162   #define XPL_LOG_DM_XPL_Warn( args... )   XPL_LOG_DM_XPL_Warn2 args
    163   #define XPL_LOG_DM_CP_Warn( args... )    XPL_LOG_DM_CP_Warn2 args
    164 #else
    165   #define XPL_LOG_DM_API_Warn( args... )
    166   #define XPL_LOG_DM_PLG_Warn( args... )
    167   #define XPL_LOG_DM_TMN_Warn( args... )
    168   #define XPL_LOG_DM_SESS_Warn( args... )
    169   #define XPL_LOG_DM_CONN_Warn( args... )
    170   #define XPL_LOG_DM_XPL_Warn( args... )
    171   #define XPL_LOG_DM_CP_Warn( args... )
    172 #endif
    173 
    174 #if ( XPL_LOG_LEVEL == XPL_LOG_DEBUG ) || ( XPL_LOG_LEVEL == XPL_LOG_ALL )
    175   #define XPL_LOG_DM_API_Debug2( args... )   XPL_LOG_Debug(XPL_LOG_PORT_DM_API,  args)
    176   #define XPL_LOG_DM_PLG_Debug2( args... )   XPL_LOG_Debug(XPL_LOG_PORT_DM_PLG,  args)
    177   #define XPL_LOG_DM_TMN_Debug2( args... )   XPL_LOG_Debug(XPL_LOG_PORT_DM_TMN,  args)
    178   #define XPL_LOG_DM_SESS_Debug2( args... )  XPL_LOG_Debug(XPL_LOG_PORT_DM_SESS, args)
    179   #define XPL_LOG_DM_CONN_Debug2( args... )  XPL_LOG_Debug(XPL_LOG_PORT_DM_CONN, args)
    180   #define XPL_LOG_DM_XPL_Debug2( args... )   XPL_LOG_Debug(XPL_LOG_PORT_DM_XPL,  args)
    181   #define XPL_LOG_DM_CP_Debug2( args... )    XPL_LOG_Debug(XPL_LOG_PORT_DM_CP,   args)
    182 
    183   #define XPL_LOG_DM_API_Enter2( args... )   XPL_LOG_Enter(XPL_LOG_PORT_DM_API,  args)
    184   #define XPL_LOG_DM_PLG_Enter2( args... )   XPL_LOG_Enter(XPL_LOG_PORT_DM_PLG,  args)
    185   #define XPL_LOG_DM_TMN_Enter2( args... )   XPL_LOG_Enter(XPL_LOG_PORT_DM_TMN,  args)
    186   #define XPL_LOG_DM_SESS_Enter2( args... )  XPL_LOG_Enter(XPL_LOG_PORT_DM_SESS, args)
    187   #define XPL_LOG_DM_CONN_Enter2( args... )  XPL_LOG_Enter(XPL_LOG_PORT_DM_CONN, args)
    188   #define XPL_LOG_DM_XPL_Enter2( args... )   XPL_LOG_Enter(XPL_LOG_PORT_DM_XPL,  args)
    189   #define XPL_LOG_DM_CP_Enter2( args... )    XPL_LOG_Enter(XPL_LOG_PORT_DM_CP,   args)
    190 
    191   #define XPL_LOG_DM_API_Leave2( args... )   XPL_LOG_Leave(XPL_LOG_PORT_DM_API,  args)
    192   #define XPL_LOG_DM_PLG_Leave2( args... )   XPL_LOG_Leave(XPL_LOG_PORT_DM_PLG,  args)
    193   #define XPL_LOG_DM_TMN_Leave2( args... )   XPL_LOG_Leave(XPL_LOG_PORT_DM_TMN,  args)
    194   #define XPL_LOG_DM_SESS_Leave2( args... )  XPL_LOG_Leave(XPL_LOG_PORT_DM_SESS, args)
    195   #define XPL_LOG_DM_CONN_Leave2( args... )  XPL_LOG_Leave(XPL_LOG_PORT_DM_CONN, args)
    196   #define XPL_LOG_DM_XPL_Leave2( args... )   XPL_LOG_Leave(XPL_LOG_PORT_DM_XPL,  args)
    197   #define XPL_LOG_DM_CP_Leave2( args... )    XPL_LOG_Leave(XPL_LOG_PORT_DM_CP,   args)
    198 
    199   #define XPL_LOG_DM_API_Debug( args... )   XPL_LOG_DM_API_Debug2 args
    200   #define XPL_LOG_DM_PLG_Debug( args... )   XPL_LOG_DM_PLG_Debug2 args
    201   #define XPL_LOG_DM_TMN_Debug( args... )   XPL_LOG_DM_TMN_Debug2 args
    202   #define XPL_LOG_DM_SESS_Debug( args... )  XPL_LOG_DM_SESS_Debug2 args
    203   #define XPL_LOG_DM_CONN_Debug( args... )  XPL_LOG_DM_CONN_Debug2 args
    204   #define XPL_LOG_DM_XPL_Debug( args... )   XPL_LOG_DM_XPL_Debug2 args
    205   #define XPL_LOG_DM_CP_Debug( args... )    XPL_LOG_DM_CP_Debug2 args
    206 
    207   #define XPL_LOG_DM_API_Enter( args... )   XPL_LOG_DM_API_Enter2 args
    208   #define XPL_LOG_DM_PLG_Enter( args... )   XPL_LOG_DM_PLG_Enter2 args
    209   #define XPL_LOG_DM_TMN_Enter( args... )   XPL_LOG_DM_TMN_Enter2 args
    210   #define XPL_LOG_DM_SESS_Enter( args... )  XPL_LOG_DM_SESS_Enter2 args
    211   #define XPL_LOG_DM_CONN_Enter( args... )  XPL_LOG_DM_CONN_Enter2 args
    212   #define XPL_LOG_DM_XPL_Enter( args... )   XPL_LOG_DM_XPL_Enter2 args
    213   #define XPL_LOG_DM_CP_Enter( args... )    XPL_LOG_DM_CP_Enter2 args
    214 
    215   #define XPL_LOG_DM_API_Leave( args... )   XPL_LOG_DM_API_Leave2 args
    216   #define XPL_LOG_DM_PLG_Leave( args... )   XPL_LOG_DM_PLG_Leave2 args
    217   #define XPL_LOG_DM_TMN_Leave( args... )   XPL_LOG_DM_TMN_Leave2 args
    218   #define XPL_LOG_DM_SESS_Leave( args... )  XPL_LOG_DM_SESS_Leave2 args
    219   #define XPL_LOG_DM_CONN_Leave( args... )  XPL_LOG_DM_CONN_Leave2 args
    220   #define XPL_LOG_DM_XPL_Leave( args... )   XPL_LOG_DM_XPL_Leave2 args
    221   #define XPL_LOG_DM_CP_Leave( args... )    XPL_LOG_DM_CP_Leave2 args
    222 #else
    223   #define XPL_LOG_DM_API_Debug( args... )
    224   #define XPL_LOG_DM_PLG_Debug( args... )
    225   #define XPL_LOG_DM_TMN_Debug( args... )
    226   #define XPL_LOG_DM_SESS_Debug( args... )
    227   #define XPL_LOG_DM_CONN_Debug( args... )
    228   #define XPL_LOG_DM_XPL_Debug( args... )
    229   #define XPL_LOG_DM_CP_Debug( args... )
    230 
    231   #define XPL_LOG_DM_API_Enter( args... )
    232   #define XPL_LOG_DM_PLG_Enter( args... )
    233   #define XPL_LOG_DM_TMN_Enter( args... )
    234   #define XPL_LOG_DM_SESS_Enter( args... )
    235   #define XPL_LOG_DM_CONN_Enter( args... )
    236   #define XPL_LOG_DM_XPL_Enter( args... )
    237   #define XPL_LOG_DM_CP_Enter( args... )
    238 
    239   #define XPL_LOG_DM_API_Leave( args... )
    240   #define XPL_LOG_DM_PLG_Leave( args... )
    241   #define XPL_LOG_DM_TMN_Leave( args... )
    242   #define XPL_LOG_DM_SESS_Leave( args... )
    243   #define XPL_LOG_DM_CONN_Leave( args... )
    244   #define XPL_LOG_DM_XPL_Leave( args... )
    245   #define XPL_LOG_DM_CP_Leave( args... )
    246 #endif
    247 
    248 #ifdef __cplusplus
    249 }
    250 #endif
    251 
    252 #endif /* XPL_LOGGER_H */
    253