#ifndef _Shark_Logger_h__
#define _Shark_Logger_h__
#include <stdarg.h>
#include "os/os_types.h"

#pragma  pack (push,1)
typedef struct {
	u16 id;
	s32 value;
}log_chan_t;
#pragma pack(pop)

void log_start_task(void);
void log_chan_value(u16 id, s32 value) ;

#define L_disable 0
#define L_debug  3
#define L_warning 2
#define L_error 1

#define LEVEL_MASK 0x03

#define mod_bit_start(mod) (mod*2)


/* define the module which need debug info here 
* at most is 32 modules (index from 0 - 31) 
*/
#define MOD_4G_AT 0  //for 4G at
#define MOD_NETWORK 1 // for network 
#define MOD_BUSINESS 2 // for business
#define MOD_BLE      3 //for ble
#define MOD_SYSTEM    4

extern void set_log_level(int mod, int l);
extern void log_debug(int mod, char *fmt, ...);
extern void log_warning(int mod, char *fmt, ...);
extern void log_error(int mod, char *fmt, ...);
void plot_3data16(s16 v1, s16 v2, s16 v3);
void plot_2data16(s16 v1, s16 v2);
void plot_1data16(s16 v1);

/* logger functions */
#define at_debug(fmt, args...) log_debug(MOD_4G_AT, "[AT:D]"fmt, ##args)
#define at_warning(fmt, args...) log_warning(MOD_4G_AT, "[AT:D]"fmt, ##args)
#define at_error(fmt, args...) log_error(MOD_4G_AT, "[AT:D]"fmt, ##args)

#define network_debug(fmt, args...) log_debug(MOD_NETWORK, "[NET:D]"fmt, ##args)
#define network_warning(fmt, args...) log_warning(MOD_NETWORK, "[NET:D]"fmt, ##args)
#define network_error(fmt, args...) log_error(MOD_NETWORK, "[NET:D]"fmt, ##args)

#define business_debug(fmt, args...) log_debug(MOD_BUSINESS, "[BUSINESS:D]"fmt, ##args)
#define business_warning(fmt, args...) log_warning(MOD_BUSINESS, "[BUSINESS:D]"fmt, ##args)
#define business_error(fmt, args...) log_error(MOD_BUSINESS, "[BUSINESS:D]"fmt, ##args)

#define ble_debug(fmt, args...) log_debug(MOD_BLE, "[BLE:D]"fmt, ##args)
#define ble_warning(fmt, args...) log_warning(MOD_BLE, "[BLE:W]"fmt, ##args)
#define ble_error(fmt, args...) log_error(MOD_BLE, fmt, "[BLE:E]"##args)

#define sys_debug(fmt, args...) log_debug(MOD_SYSTEM, "D"fmt, ##args)
#define sys_warning(fmt, args...) log_warning(MOD_SYSTEM, fmt, ##args)
#define sys_error(fmt, args...) log_error(MOD_SYSTEM, fmt, ##args)

#define no_debug(fmt, args...) {}

#endif /* _Shark_Logger_h__ */

