glib-log-handler.c
来自「MANTIS是由科罗拉多大学开发的传感器网络嵌入式操作系统。 这是mantis」· C语言 代码 · 共 58 行
C
58 行
#include <stdio.h>#include <syslog.h>#include <glib.h>#include "bionet-util.h"void bionet_glib_log_handler( const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer log_context) { static bionet_log_context_t default_log_context = { destination: BIONET_LOG_TO_STDOUT, log_limit: G_LOG_LEVEL_INFO }; bionet_log_context_t *lc; if (log_context == NULL) { lc = &default_log_context; } else { lc = log_context; } if (log_level > lc->log_limit) return; switch (lc->destination) { case BIONET_LOG_TO_SYSLOG: { if ((log_domain == NULL) || (log_domain[0] == '\0')) { syslog(LOG_INFO, "%s", message); } else { syslog(LOG_INFO, "%s: %s\n", log_domain, message); } return; } case BIONET_LOG_TO_STDOUT: { if ((log_domain == NULL) || (log_domain[0] == '\0')) { printf("%s\n", message); } else { printf("%s: %s\n", log_domain, message); } return; } default: { return; } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?