void noit_log_init() { noit_hash_init(&noit_loggers); noit_hash_init(&noit_logops); noit_register_logops("file", &posix_logio_ops); noit_register_logops("jlog", &jlog_logio_ops); noit_stderr = noit_log_stream_new_on_fd("stderr", 2, NULL); noit_stderr->timestamps = 1; noit_error = noit_log_stream_new("error", NULL, NULL, NULL, NULL); noit_debug = noit_log_stream_new("debug", NULL, NULL, NULL, NULL); }
void noit_log_init(int debug_on) { noit_hash_init(&noit_loggers); noit_hash_init(&noit_logops); noit_register_logops("file", &posix_logio_ops); noit_register_logops("jlog", &jlog_logio_ops); noit_register_logops("memory", &membuf_logio_ops); noit_stderr = noit_log_stream_new_on_fd("stderr", 2, NULL); noit_stderr->flags |= NOIT_LOG_STREAM_TIMESTAMPS; noit_stderr->flags |= NOIT_LOG_STREAM_FACILITY; noit_error = noit_log_stream_new("error", NULL, NULL, NULL, NULL); noit_debug = noit_log_stream_new("debug", NULL, NULL, NULL, NULL); noit_notice = noit_log_stream_new("notice", NULL, NULL, NULL, NULL); noit_debug->flags = (noit_debug->flags & ~NOIT_LOG_STREAM_DEBUG) | (debug_on ? NOIT_LOG_STREAM_DEBUG : 0); if(debug_on) noit_debug->flags |= NOIT_LOG_STREAM_ENABLED; else noit_debug->flags &= ~NOIT_LOG_STREAM_ENABLED; }
void noit_log_stream_set_property(noit_log_stream_t ls, const char *prop, const char *v) { if(!ls) return; if(!ls->config) { ls->config = calloc(1, sizeof(*ls->config)); noit_hash_init(ls->config); } noit_hash_replace(ls->config, prop, strlen(prop), (void *)v, free, free); }
noit_console_closure_t noit_console_closure_alloc() { noit_console_closure_t new_ncct; new_ncct = calloc(1, sizeof(*new_ncct)); noit_hash_init(&new_ncct->userdata); noit_console_state_push_state(new_ncct, noit_console_state_initial()); new_ncct->pty_master = -1; new_ncct->pty_slave = -1; return new_ncct; }