modbusd
modbus master daemon
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
log.h File Reference

Logging system (Syslog Marcos) More...

#include <syslog.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for log.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define MSG_LEN   256
 
#define ERR(flag, fmt,...)
 
#define LOG(flag, fmt,...)
 
#define BEGIN(flag)
 
#define END(flag)
 

Detailed Description

Logging system (Syslog Marcos)

Author
Taka Wang

Macro Definition Documentation

#define BEGIN (   flag)
#define END (   flag)
Value:
do { \
snprintf(cstr, sizeof(cstr), "[END][%s:%d]", __func__, __LINE__); \
switch (flag) \
{ \
case 0: { break;} \
case 1: { printf("%s\n", cstr); } \
default: { syslog(LOG_DEBUG, "%s", cstr); break; } \
} \
} while (0)

Referenced by mbtcp_get_response_timeout(), mbtcp_list_handles(), and mbtcp_set_response_timeout().

#define ERR (   flag,
  fmt,
  ... 
)
Value:
do { \
snprintf(cstr, sizeof(cstr), "[%s:%d]: " fmt, __func__, __LINE__, ##__VA_ARGS__); \
switch (flag) \
{ \
case 0: { break;} \
case 1: { printf("[ERROR]%s\n", cstr); } \
default: { syslog(LOG_ERR, "%s", cstr); break; } \
} \
} while (0)

Referenced by mbtcp_do_connect(), mbtcp_get_connection_status(), mbtcp_get_handle(), mbtcp_init_handle(), set_modbus_fail_resp_str(), and set_modbus_fail_resp_str_with_errno().

#define LOG (   flag,
  fmt,
  ... 
)
Value:
do { \
snprintf(cstr, sizeof(cstr), "[%s:%d]: " fmt, __func__, __LINE__, ##__VA_ARGS__); \
switch (flag) \
{ \
case 0: { break;} \
case 1: { printf("[LOG]%s\n", cstr); } \
default: { syslog(LOG_INFO, "%s", cstr); break; } \
} \
} while (0)

Referenced by main(), mbtcp_cmd_hanlder(), mbtcp_do_connect(), mbtcp_get_connection_status(), mbtcp_get_handle(), mbtcp_get_response_timeout(), mbtcp_init_handle(), mbtcp_list_handles(), mbtcp_multi_write_req_fn(), mbtcp_read_bit_req_fn(), mbtcp_read_reg_req_fn(), mbtcp_set_response_timeout(), set_modbus_fail_resp_str(), set_modbus_success_resp_str_with_data(), test_init_tcp_handle_and_connect(), test_multiple_add_find(), and test_single_add_find().

#define MSG_LEN   256