Annotation of mqtt/src/logmqtt.c, revision 1.1.2.2
1.1.2.1 misho 1: #include "global.h"
2:
3:
1.1.2.2 ! misho 4: /*
! 5: * mqtt_rtlm_log() Log message
! 6: *
! 7: * @fmt = format string
! 8: * @... = argument list
! 9: * return: none
! 10: */
! 11: static void
! 12: mqtt_rtlm_log(const char *fmt, ...)
! 13: {
! 14: va_list lst;
! 15:
! 16: va_start(lst, fmt);
! 17: vsyslog(LOG_ERR, fmt, lst);
! 18: va_end(lst);
! 19: }
! 20: #define MQTT_RTLM_LOG() (mqtt_rtlm_log("Error:: System #%d - %s", errno, strerror(errno)))
! 21:
! 22:
! 23: /*
! 24: * mqtt_rtlm_open() Open log file
! 25: *
! 26: * @cfg = loaded config
! 27: * return: NULL error or SQL handle
! 28: */
! 29: FILE *
! 30: mqtt_rtlm_open(sl_config *cfg)
! 31: {
! 32: FILE *f = NULL;
! 33: const char *str = NULL;
! 34:
! 35: if (!cfg)
! 36: return NULL;
! 37:
! 38: str = (const char*) cfg_GetAttribute(cfg, CFG("mqtt_log"), CFG("name"));
! 39: if (!str) {
! 40: mqtt_rtlm_log("Error:: Unknown file name ...\n");
! 41: return NULL;
! 42: }
! 43:
! 44: if (!(f = fopen(str, "a"))) {
! 45: MQTT_RTLM_LOG();
! 46: return NULL;
! 47: }
! 48:
! 49: return f;
! 50: }
! 51:
! 52: /*
! 53: * mqtt_rtlm_close() Close log file
! 54: *
! 55: * @f = File handle
! 56: * return: none
! 57: */
! 58: void
! 59: mqtt_rtlm_close(FILE *f)
! 60: {
! 61: if (f)
! 62: fclose(f);
! 63: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>