void dleyna_log_init(const char *program, const char *version) { int option = LOG_NDELAY | LOG_PID; int old; #ifdef DLEYNA_DEBUG_ENABLED option |= LOG_PERROR | LOG_CONS; #endif memset(&s_log_context, 0, sizeof(s_log_context)); s_log_context.log_domain = g_strdup(program); prv_set_flags_from_param(); openlog(basename(program), option, LOG_DAEMON); old = setlogmask(LOG_MASK(LOG_INFO)); syslog(LOG_INFO, "dLeyna core version %s", VERSION); syslog(LOG_INFO, "%s version %s", program, version); (void) setlogmask(s_log_context.mask); s_log_context.old_mask = old; s_log_context.old_handler = g_log_set_default_handler( prv_handler, &s_log_context); #if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_INFO if (s_log_context.log_type != DLEYNA_LOG_TYPE_SYSLOG) { DLEYNA_LOG_INFO("dLeyna core version %s", VERSION); DLEYNA_LOG_INFO("%s version %s", program, version); } #endif }
static void prv_dlr_method_call(dleyna_connector_id_t conn, const gchar *sender, const gchar *object, const gchar *interface, const gchar *method, GVariant *parameters, dleyna_connector_msg_id_t invocation) { dlr_task_t *task; DLEYNA_LOG_INFO("Calling %s method", method); if (!strcmp(method, DLR_INTERFACE_RELEASE)) { g_context.connector->unwatch_client(sender); prv_remove_client(sender); g_context.connector->return_response(invocation, NULL); } else { if (!strcmp(method, DLR_INTERFACE_GET_VERSION)) task = dlr_task_get_version_new(invocation); else if (!strcmp(method, DLR_INTERFACE_GET_SERVERS)) task = dlr_task_get_servers_new(invocation); else goto finished; prv_add_task(task, sender, DLR_RENDERER_SINK); } finished: return; }
void dleyna_log_update_type_level(dleyna_log_type_t log_type, int log_level) { int mask; int compile_mask; GLogLevelFlags flags; GLogLevelFlags compile_flags; s_log_context.log_type = log_type; prv_get_mf(log_level, &mask, &flags); prv_get_mf(DLEYNA_LOG_LEVEL, &compile_mask, &compile_flags); /* log level read from conf file is a subset of log level * set at compile time. * Only keep subset flags from compile flags */ mask &= compile_mask; flags &= compile_flags; s_log_context.mask = mask; s_log_context.flags = flags; DLEYNA_LOG_INFO("Type[%d] Level[0x%02X] Mask[0x%02X] Flags[0x%02X]", log_type, log_level, mask, flags); (void) setlogmask(mask); }
static void prv_manager_root_method_call(dleyna_connector_id_t conn, const gchar *sender, const gchar *object, const gchar *interface, const gchar *method, GVariant *parameters, dleyna_connector_msg_id_t invocation) { dld_task_t *task; DLEYNA_LOG_INFO("Calling %s method", method); if (!strcmp(method, DLD_INTERFACE_RELEASE)) { g_context.connector->unwatch_client(sender); prv_remove_client(sender); g_context.connector->return_response(invocation, NULL); goto finished; } else { if (!strcmp(method, DLD_INTERFACE_GET_VERSION)) task = dld_task_get_version_new(invocation); else if (!strcmp(method, DLD_INTERFACE_GET_DEVICES)) task = dld_task_get_devices_new(invocation); else if (!strcmp(method, DLD_INTERFACE_RESCAN)) task = dld_task_rescan_new(invocation); else goto finished; } prv_add_task(task, sender, DLD_DIAGNOSTICS_SINK); finished: return; }
static void prv_found_media_server(const gchar *path) { DLEYNA_LOG_INFO("New media server %s", path); (void) g_context.connector->notify(g_context.connection, DLEYNA_SERVER_OBJECT, DLEYNA_SERVER_INTERFACE_MANAGER, DLR_INTERFACE_FOUND_SERVER, g_variant_new("(s)", path), NULL); }
static void prv_found_diagnostics_device(const gchar *path) { DLEYNA_LOG_INFO("New Diagnostics Device: %s", path); (void) g_context.connector->notify(g_context.connection, DLEYNA_DIAGNOSTICS_OBJECT, DLEYNA_DIAGNOSTICS_INTERFACE_MANAGER, DLD_INTERFACE_FOUND_DEVICE, g_variant_new("(o)", path), NULL); }
static void prv_lost_media_server(const gchar *path) { DLEYNA_LOG_INFO("Lost %s", path); (void) g_context.connector->notify(g_context.connection, DLEYNA_SERVER_OBJECT, DLEYNA_SERVER_INTERFACE_MANAGER, DLR_INTERFACE_LOST_SERVER, g_variant_new("(s)", path), NULL); dleyna_task_processor_remove_queues_for_sink(g_context.processor, path); }
static void prv_lost_diagnostics_device(const gchar *path) { DLEYNA_LOG_INFO("Lost: %s", path); (void) g_context.connector->notify(g_context.connection, DLEYNA_DIAGNOSTICS_OBJECT, DLEYNA_DIAGNOSTICS_INTERFACE_MANAGER, DLD_INTERFACE_LOST_DEVICE, g_variant_new("(o)", path), NULL); dleyna_task_processor_remove_queues_for_sink(g_context.processor, path); }
void dleyna_log_finalize(void) { (void) setlogmask(LOG_MASK(LOG_INFO)); syslog(LOG_INFO, "dLeyna: Exit"); #if DLEYNA_LOG_LEVEL & DLEYNA_LOG_LEVEL_INFO if (s_log_context.log_type != DLEYNA_LOG_TYPE_SYSLOG) DLEYNA_LOG_INFO("dLeyna: Exit"); #endif (void) g_log_set_default_handler(s_log_context.old_handler, NULL); (void) setlogmask(s_log_context.old_mask); closelog(); g_free(s_log_context.log_domain); memset(&s_log_context, 0, sizeof(s_log_context)); }
static void prv_lost_client(const gchar *name) { DLEYNA_LOG_INFO("Client %s lost", name); prv_remove_client(name); }