summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2018-03-05 17:32:50 +0300
committerValentin Bartenev <vbart@nginx.com>2018-03-05 17:32:50 +0300
commit912a49c6091c1fd9b630d2e0966f0fe1b97a3e42 (patch)
tree5581735807436384796dfd9deff336865c8372e4 /src
parentf2090bce21e4fb47d11f992a76ef5c4da74c3233 (diff)
downloadunit-912a49c6091c1fd9b630d2e0966f0fe1b97a3e42.tar.gz
unit-912a49c6091c1fd9b630d2e0966f0fe1b97a3e42.tar.bz2
Reduced number of critical log levels.
Diffstat (limited to 'src')
-rw-r--r--src/nxt_app_log.c2
-rw-r--r--src/nxt_application.c15
-rw-r--r--src/nxt_buf.c23
-rw-r--r--src/nxt_conn.c6
-rw-r--r--src/nxt_conn_accept.c16
-rw-r--r--src/nxt_conn_close.c5
-rw-r--r--src/nxt_controller.c11
-rw-r--r--src/nxt_cyassl.c14
-rw-r--r--src/nxt_devpoll_engine.c30
-rw-r--r--src/nxt_epoll_engine.c48
-rw-r--r--src/nxt_event_engine.c7
-rw-r--r--src/nxt_eventport_engine.c43
-rw-r--r--src/nxt_fd_event.c4
-rw-r--r--src/nxt_fiber.c29
-rw-r--r--src/nxt_file.c58
-rw-r--r--src/nxt_file.h2
-rw-r--r--src/nxt_gnutls.c20
-rw-r--r--src/nxt_go.c15
-rw-r--r--src/nxt_kqueue_engine.c38
-rw-r--r--src/nxt_listen_socket.c11
-rw-r--r--src/nxt_log.c6
-rw-r--r--src/nxt_log.h43
-rw-r--r--src/nxt_log_moderation.h11
-rw-r--r--src/nxt_main_process.c34
-rw-r--r--src/nxt_malloc.c30
-rw-r--r--src/nxt_mem_zone.c3
-rw-r--r--src/nxt_mp.c5
-rw-r--r--src/nxt_openssl.c23
-rw-r--r--src/nxt_php_sapi.c10
-rw-r--r--src/nxt_polarssl.c6
-rw-r--r--src/nxt_poll_engine.c21
-rw-r--r--src/nxt_pollset_engine.c30
-rw-r--r--src/nxt_port.c4
-rw-r--r--src/nxt_port_memory.c13
-rw-r--r--src/nxt_port_socket.c17
-rw-r--r--src/nxt_process.c63
-rw-r--r--src/nxt_python_wsgi.c75
-rw-r--r--src/nxt_router.c29
-rw-r--r--src/nxt_runtime.c36
-rw-r--r--src/nxt_service.c4
-rw-r--r--src/nxt_socket.c29
-rw-r--r--src/nxt_socketpair.c10
-rw-r--r--src/nxt_thread.c2
-rw-r--r--src/nxt_thread_cond.c2
-rw-r--r--src/nxt_thread_log.h9
-rw-r--r--src/nxt_thread_mutex.c6
-rw-r--r--src/perl/nxt_perl_psgi.c19
47 files changed, 403 insertions, 534 deletions
diff --git a/src/nxt_app_log.c b/src/nxt_app_log.c
index 013fae46..9bd85458 100644
--- a/src/nxt_app_log.c
+++ b/src/nxt_app_log.c
@@ -79,7 +79,7 @@ nxt_log_time_handler(nxt_uint_t level, nxt_log_t *log, const char *fmt, ...)
(void) nxt_write_console(nxt_stderr, msg, p - msg);
- if (level <= NXT_LOG_ALERT) {
+ if (level == NXT_LOG_ALERT) {
*(p - NXT_LINEFEED_SIZE) = '\0';
/*
diff --git a/src/nxt_application.c b/src/nxt_application.c
index f9ac8a7f..cad4ac8d 100644
--- a/src/nxt_application.c
+++ b/src/nxt_application.c
@@ -196,8 +196,7 @@ nxt_discovery_module(nxt_task_t *task, nxt_mp_t *mp, nxt_array_t *modules,
dl = dlopen(name, RTLD_GLOBAL | RTLD_NOW);
if (dl == NULL) {
- nxt_log(task, NXT_LOG_CRIT, "dlopen(\"%s\"), failed: \"%s\"",
- name, dlerror());
+ nxt_alert(task, "dlopen(\"%s\"), failed: \"%s\"", name, dlerror());
return NXT_OK;
}
@@ -262,8 +261,7 @@ nxt_discovery_module(nxt_task_t *task, nxt_mp_t *mp, nxt_array_t *modules,
nxt_memcpy(module->file.start, name, module->file.length);
} else {
- nxt_log(task, NXT_LOG_CRIT, "dlsym(\"%s\"), failed: \"%s\"",
- name, dlerror());
+ nxt_alert(task, "dlsym(\"%s\"), failed: \"%s\"", name, dlerror());
}
done:
@@ -273,8 +271,7 @@ done:
fail:
if (dlclose(dl) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "dlclose(\"%s\"), failed: \"%s\"",
- name, dlerror());
+ nxt_alert(task, "dlclose(\"%s\"), failed: \"%s\"", name, dlerror());
}
return ret;
@@ -312,8 +309,7 @@ nxt_app_start(nxt_task_t *task, void *data)
lang = nxt_app_lang_module(task->thread->runtime, &app_conf->type);
if (nxt_slow_path(lang == NULL)) {
- nxt_log(task, NXT_LOG_CRIT, "unknown application type: \"%V\"",
- &app_conf->type);
+ nxt_alert(task, "unknown application type: \"%V\"", &app_conf->type);
return NXT_ERROR;
}
@@ -371,8 +367,7 @@ nxt_app_module_load(nxt_task_t *task, const char *name)
return dlsym(dl, "nxt_app_module");
}
- nxt_log(task, NXT_LOG_CRIT, "dlopen(\"%s\"), failed: \"%s\"",
- name, dlerror());
+ nxt_alert(task, "dlopen(\"%s\"), failed: \"%s\"", name, dlerror());
return NULL;
}
diff --git a/src/nxt_buf.c b/src/nxt_buf.c
index 36a1dcd0..c764fecd 100644
--- a/src/nxt_buf.c
+++ b/src/nxt_buf.c
@@ -202,13 +202,7 @@ nxt_buf_completion(nxt_task_t *task, void *obj, void *data)
nxt_debug(task, "buf completion: %p %p", b, b->mem.start);
-#if (NXT_DEBUG)
- if (nxt_slow_path(data != b->parent)) {
- nxt_log_alert(task->log, "completion data (%p) != b->parent (%p)",
- data, b->parent);
- nxt_abort();
- }
-#endif
+ nxt_assert(data == b->parent);
mp = b->data;
nxt_mp_free(mp, b);
@@ -235,12 +229,7 @@ nxt_buf_ts_handle(nxt_task_t *task, void *obj, void *data)
b = obj;
-#if (NXT_DEBUG)
- if (nxt_slow_path(b->is_ts == 0)) {
- nxt_log_alert(task->log, "not a thread safe buf (%p) completed", b);
- nxt_abort();
- }
-#endif
+ nxt_assert(b->is_ts != 0);
ts = nxt_pointer_to(b, NXT_BUF_MEM_SIZE);
@@ -277,13 +266,7 @@ nxt_buf_ts_completion(nxt_task_t *task, void *obj, void *data)
nxt_debug(task, "buf ts completion: %p %p", b, b->mem.start);
-#if (NXT_DEBUG)
- if (nxt_slow_path(data != b->parent)) {
- nxt_log_alert(task->log, "completion data (%p) != b->parent (%p)",
- data, b->parent);
- nxt_abort();
- }
-#endif
+ nxt_assert(data == b->parent);
mp = b->data;
nxt_mp_free(mp, b);
diff --git a/src/nxt_conn.c b/src/nxt_conn.c
index 6d0182e3..c451a38b 100644
--- a/src/nxt_conn.c
+++ b/src/nxt_conn.c
@@ -129,8 +129,8 @@ nxt_conn_io_shutdown(nxt_task_t *task, void *obj, void *data)
sizeof(struct linger));
if (nxt_slow_path(ret != 0)) {
- nxt_log(task, NXT_LOG_CRIT, "setsockopt(%d, SO_LINGER) failed %E",
- c->socket.fd, nxt_socket_errno);
+ nxt_alert(task, "setsockopt(%d, SO_LINGER) failed %E",
+ c->socket.fd, nxt_socket_errno);
}
}
@@ -205,7 +205,7 @@ nxt_conn_local_addr(nxt_task_t *task, nxt_conn_t *c)
ret = getsockname(c->socket.fd, &sa->u.sockaddr, &socklen);
if (nxt_slow_path(ret != 0)) {
- nxt_log(task, NXT_LOG_CRIT, "getsockname(%d) failed", c->socket.fd);
+ nxt_alert(task, "getsockname(%d) failed", c->socket.fd);
return NULL;
}
diff --git a/src/nxt_conn_accept.c b/src/nxt_conn_accept.c
index 80b599b4..a2aaa940 100644
--- a/src/nxt_conn_accept.c
+++ b/src/nxt_conn_accept.c
@@ -234,8 +234,8 @@ nxt_conn_accept_next(nxt_task_t *task, nxt_listen_event_t *lev)
} while (nxt_conn_accept_close_idle(task, lev) == NXT_OK);
- nxt_log(task, NXT_LOG_CRIT, "no available connections, "
- "new connections are not accepted within 1s");
+ nxt_alert(task, "no available connections, "
+ "new connections are not accepted within 1s");
return NULL;
}
@@ -309,16 +309,16 @@ nxt_conn_accept_error(nxt_task_t *task, nxt_listen_event_t *lev,
case ENOBUFS:
case ENOMEM:
if (nxt_conn_accept_close_idle(task, lev) != NXT_OK) {
- nxt_log(task, NXT_LOG_CRIT, "%s(%d) failed %E, "
- "new connections are not accepted within 1s",
- accept_syscall, lev->socket.fd, err);
+ nxt_alert(task, "%s(%d) failed %E, "
+ "new connections are not accepted within 1s",
+ accept_syscall, lev->socket.fd, err);
}
return;
default:
- nxt_log(task, NXT_LOG_CRIT, "%s(%d) failed %E",
- accept_syscall, lev->socket.fd, err);
+ nxt_alert(task, "%s(%d) failed %E",
+ accept_syscall, lev->socket.fd, err);
return;
}
}
@@ -357,5 +357,5 @@ nxt_conn_listen_event_error(nxt_task_t *task, void *obj, void *data)
ev = obj;
- nxt_log(task, NXT_LOG_CRIT, "accept(%d) event error", ev->fd);
+ nxt_alert(task, "accept(%d) event error", ev->fd);
}
diff --git a/src/nxt_conn_close.c b/src/nxt_conn_close.c
index f9586624..7c130309 100644
--- a/src/nxt_conn_close.c
+++ b/src/nxt_conn_close.c
@@ -46,9 +46,8 @@ nxt_conn_close(nxt_event_engine_t *engine, nxt_conn_t *c)
sizeof(struct linger));
if (nxt_slow_path(ret != 0)) {
- nxt_log(c->socket.task, NXT_LOG_CRIT,
- "setsockopt(%d, SO_LINGER) failed %E",
- c->socket.fd, nxt_socket_errno);
+ nxt_alert(c->socket.task, "setsockopt(%d, SO_LINGER) failed %E",
+ c->socket.fd, nxt_socket_errno);
}
}
diff --git a/src/nxt_controller.c b/src/nxt_controller.c
index 0a65ada7..6c477157 100644
--- a/src/nxt_controller.c
+++ b/src/nxt_controller.c
@@ -154,9 +154,8 @@ nxt_controller_start(nxt_task_t *task, void *data)
nxt_free(json->start);
if (nxt_slow_path(conf == NULL)) {
- nxt_log(task, NXT_LOG_ALERT,
- "failed to restore previous configuration: "
- "file is corrupted or not enough memory");
+ nxt_alert(task, "failed to restore previous configuration: "
+ "file is corrupted or not enough memory");
nxt_mp_destroy(mp);
return NXT_OK;
@@ -176,8 +175,8 @@ nxt_controller_start(nxt_task_t *task, void *data)
if (nxt_slow_path(ret != NXT_OK)) {
if (ret == NXT_DECLINED) {
- nxt_log(task, NXT_LOG_ALERT,
- "the previous configuration is invalid: %V", &vldt.error);
+ nxt_alert(task, "the previous configuration is invalid: %V",
+ &vldt.error);
nxt_mp_destroy(vldt.pool);
nxt_mp_destroy(mp);
@@ -279,7 +278,7 @@ nxt_controller_conf_init_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg,
nxt_runtime_t *rt;
if (msg->port_msg.type != NXT_PORT_MSG_RPC_READY) {
- nxt_log(task, NXT_LOG_ALERT, "failed to apply previous configuration");
+ nxt_alert(task, "failed to apply previous configuration");
nxt_mp_destroy(nxt_controller_conf.pool);
diff --git a/src/nxt_cyassl.c b/src/nxt_cyassl.c
index 3d487183..91039e0c 100644
--- a/src/nxt_cyassl.c
+++ b/src/nxt_cyassl.c
@@ -87,7 +87,7 @@ nxt_cyassl_start(void)
err = CyaSSL_Init();
if (err != SSL_SUCCESS) {
- nxt_cyassl_log_error(NXT_LOG_CRIT, thr->log, err,
+ nxt_cyassl_log_error(NXT_LOG_ALERT, thr->log, err,
"CyaSSL_Init() failed");
return NXT_ERROR;
}
@@ -118,7 +118,7 @@ nxt_cyassl_server_init(nxt_ssltls_conf_t *conf)
ctx = CyaSSL_CTX_new(CyaSSLv23_server_method());
if (ctx == NULL) {
- nxt_cyassl_log_error(NXT_LOG_CRIT, thr->log, 0,
+ nxt_cyassl_log_error(NXT_LOG_ALERT, thr->log, 0,
"CyaSSL_CTX_new() failed");
return NXT_ERROR;
}
@@ -130,7 +130,7 @@ nxt_cyassl_server_init(nxt_ssltls_conf_t *conf)
err = CyaSSL_CTX_use_certificate_file(ctx, certificate, SSL_FILETYPE_PEM);
if (err != SSL_SUCCESS) {
- nxt_cyassl_log_error(NXT_LOG_CRIT, thr->log, err,
+ nxt_cyassl_log_error(NXT_LOG_ALERT, thr->log, err,
"CyaSSL_CTX_use_certificate_file(\"%s\") failed",
certificate);
goto fail;
@@ -140,7 +140,7 @@ nxt_cyassl_server_init(nxt_ssltls_conf_t *conf)
err = CyaSSL_CTX_use_PrivateKey_file(ctx, key, SSL_FILETYPE_PEM);
if (err != SSL_SUCCESS) {
- nxt_cyassl_log_error(NXT_LOG_CRIT, thr->log, err,
+ nxt_cyassl_log_error(NXT_LOG_ALERT, thr->log, err,
"CyaSSL_CTX_use_PrivateKey_file(\"%s\") failed",
key);
goto fail;
@@ -149,7 +149,7 @@ nxt_cyassl_server_init(nxt_ssltls_conf_t *conf)
if (conf->ciphers != NULL) {
err = CyaSSL_CTX_set_cipher_list(ctx, conf->ciphers);
if (err != SSL_SUCCESS) {
- nxt_cyassl_log_error(NXT_LOG_CRIT, thr->log, err,
+ nxt_cyassl_log_error(NXT_LOG_ALERT, thr->log, err,
"CyaSSL_CTX_set_cipher_list(\"%s\") failed",
conf->ciphers);
goto fail;
@@ -199,7 +199,7 @@ nxt_cyassl_conn_init(nxt_thread_t *thr, nxt_ssltls_conf_t *conf,
s = CyaSSL_new(ctx);
if (s == NULL) {
- nxt_cyassl_log_error(NXT_LOG_CRIT, c->socket.log, 0,
+ nxt_cyassl_log_error(NXT_LOG_ALERT, c->socket.log, 0,
"CyaSSL_new() failed");
goto fail;
}
@@ -574,7 +574,7 @@ nxt_cyassl_log_error_level(nxt_event_conn_t *c, nxt_err_t err, int ssl_error)
break;
default:
- return NXT_LOG_CRIT;
+ return NXT_LOG_ALERT;
}
return NXT_LOG_INFO;
diff --git a/src/nxt_devpoll_engine.c b/src/nxt_devpoll_engine.c
index 07b08189..71ab11a3 100644
--- a/src/nxt_devpoll_engine.c
+++ b/src/nxt_devpoll_engine.c
@@ -128,8 +128,7 @@ nxt_devpoll_create(nxt_event_engine_t *engine, nxt_uint_t mchanges,
engine->u.devpoll.fd = open("/dev/poll", O_RDWR);
if (engine->u.devpoll.fd == -1) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "open(\"/dev/poll\") failed %E",
- nxt_errno);
+ nxt_alert(&engine->task, "open(\"/dev/poll\") failed %E", nxt_errno);
goto fail;
}
@@ -155,8 +154,7 @@ nxt_devpoll_free(nxt_event_engine_t *engine)
nxt_debug(&engine->task, "devpoll %d free", fd);
if (fd != -1 && close(fd) != 0) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "devpoll close(%d) failed %E",
- fd, nxt_errno);
+ nxt_alert(&engine->task, "devpoll close(%d) failed %E", fd, nxt_errno);
}
nxt_free(engine->u.devpoll.events);
@@ -515,9 +513,8 @@ nxt_devpoll_remove(nxt_event_engine_t *engine, nxt_fd_t fd)
}
if (n == -1) {
- nxt_log(&engine->task, NXT_LOG_CRIT,
- "ioctl(%d, DP_ISPOLLED, %d) failed %E",
- engine->u.devpoll.fd, fd, nxt_errno);
+ nxt_alert(&engine->task, "ioctl(%d, DP_ISPOLLED, %d) failed %E",
+ engine->u.devpoll.fd, fd, nxt_errno);
/* Fall through. */
}
@@ -549,8 +546,7 @@ nxt_devpoll_write(nxt_event_engine_t *engine, struct pollfd *pfd, size_t n)
return NXT_OK;
}
- nxt_log(&engine->task, NXT_LOG_CRIT, "devpoll write(%d) failed %E",
- fd, nxt_errno);
+ nxt_alert(&engine->task, "devpoll write(%d) failed %E", fd, nxt_errno);
return NXT_ERROR;
}
@@ -592,7 +588,7 @@ nxt_devpoll_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
engine->u.devpoll.fd, nevents);
if (nevents == -1) {
- level = (err == NXT_EINTR) ? NXT_LOG_INFO : NXT_LOG_CRIT;
+ level = (err == NXT_EINTR) ? NXT_LOG_INFO : NXT_LOG_ALERT;
nxt_log(&engine->task, level, "ioctl(%d, DP_POLL) failed %E",
engine->u.devpoll.fd, err);
@@ -610,10 +606,10 @@ nxt_devpoll_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
fd);
if (nxt_slow_path(ev == NULL)) {
- nxt_log(&engine->task, NXT_LOG_CRIT,
- "ioctl(%d, DP_POLL) returned invalid "
- "fd:%d ev:%04Xd rev:%04uXi",
- engine->u.devpoll.fd, fd, pfd->events, events);
+ nxt_alert(&engine->task,
+ "ioctl(%d, DP_POLL) returned invalid "
+ "fd:%d ev:%04Xd rev:%04uXi",
+ engine->u.devpoll.fd, fd, pfd->events, events);
nxt_devpoll_remove(engine, fd);
continue;
@@ -623,9 +619,9 @@ nxt_devpoll_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
fd, events, ev->read, ev->write);
if (nxt_slow_path(events & (POLLERR | POLLHUP | POLLNVAL)) != 0) {
- nxt_log(ev->task, NXT_LOG_CRIT,
- "ioctl(%d, DP_POLL) error fd:%d ev:%04Xd rev:%04uXi",
- engine->u.devpoll.fd, fd, pfd->events, events);
+ nxt_alert(ev->task,
+ "ioctl(%d, DP_POLL) error fd:%d ev:%04Xd rev:%04uXi",
+ engine->u.devpoll.fd, fd, pfd->events, events);
nxt_work_queue_add(&engine->fast_work_queue, ev->error_handler,
ev->task, ev, ev->data);
diff --git a/src/nxt_epoll_engine.c b/src/nxt_epoll_engine.c
index c70daa99..15aa4481 100644
--- a/src/nxt_epoll_engine.c
+++ b/src/nxt_epoll_engine.c
@@ -256,8 +256,7 @@ nxt_epoll_create(nxt_event_engine_t *engine, nxt_uint_t mchanges,
engine->u.epoll.fd = epoll_create(1);
if (engine->u.epoll.fd == -1) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "epoll_create() failed %E",
- nxt_errno);
+ nxt_alert(&engine->task, "epoll_create() failed %E", nxt_errno);
goto fail;
}
@@ -326,8 +325,7 @@ nxt_epoll_free(nxt_event_engine_t *engine)
fd = engine->u.epoll.signalfd.fd;
if (fd != -1 && close(fd) != 0) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "signalfd close(%d) failed %E",
- fd, nxt_errno);
+ nxt_alert(&engine->task, "signalfd close(%d) failed %E", fd, nxt_errno);
}
#endif
@@ -337,8 +335,7 @@ nxt_epoll_free(nxt_event_engine_t *engine)
fd = engine->u.epoll.eventfd.fd;
if (fd != -1 && close(fd) != 0) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "eventfd close(%d) failed %E",
- fd, nxt_errno);
+ nxt_alert(&engine->task, "eventfd close(%d) failed %E", fd, nxt_errno);
}
#endif
@@ -346,8 +343,7 @@ nxt_epoll_free(nxt_event_engine_t *engine)
fd = engine->u.epoll.fd;
if (fd != -1 && close(fd) != 0) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "epoll close(%d) failed %E",
- fd, nxt_errno);
+ nxt_alert(&engine->task, "epoll close(%d) failed %E", fd, nxt_errno);
}
nxt_free(engine->u.epoll.events);
@@ -637,8 +633,8 @@ nxt_epoll_commit_changes(nxt_event_engine_t *engine)
ret = epoll_ctl(engine->u.epoll.fd, change->op, ev->fd, &change->event);
if (nxt_slow_path(ret != 0)) {
- nxt_log(ev->task, NXT_LOG_CRIT, "epoll_ctl(%d, %d, %d) failed %E",
- engine->u.epoll.fd, change->op, ev->fd, nxt_errno);
+ nxt_alert(ev->task, "epoll_ctl(%d, %d, %d) failed %E",
+ engine->u.epoll.fd, change->op, ev->fd, nxt_errno);
nxt_work_queue_add(&engine->fast_work_queue,
nxt_epoll_error_handler, ev->task, ev, ev->data);
@@ -679,8 +675,7 @@ nxt_epoll_add_signal(nxt_event_engine_t *engine)
struct epoll_event ee;
if (sigprocmask(SIG_BLOCK, &engine->signals->sigmask, NULL) != 0) {
- nxt_log(&engine->task, NXT_LOG_CRIT,
- "sigprocmask(SIG_BLOCK) failed %E", nxt_errno);
+ nxt_alert(&engine->task, "sigprocmask(SIG_BLOCK) failed %E", nxt_errno);
return NXT_ERROR;
}
@@ -696,8 +691,8 @@ nxt_epoll_add_signal(nxt_event_engine_t *engine)
fd = signalfd(-1, &engine->signals->sigmask, 0);
if (fd == -1) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "signalfd(%d) failed %E",
- engine->u.epoll.signalfd.fd, nxt_errno);
+ nxt_alert(&engine->task, "signalfd(%d) failed %E",
+ engine->u.epoll.signalfd.fd, nxt_errno);
return NXT_ERROR;
}
@@ -719,8 +714,8 @@ nxt_epoll_add_signal(nxt_event_engine_t *engine)
ee.data.ptr = &engine->u.epoll.signalfd;
if (epoll_ctl(engine->u.epoll.fd, EPOLL_CTL_ADD, fd, &ee) != 0) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "epoll_ctl(%d, %d, %d) failed %E",
- engine->u.epoll.fd, EPOLL_CTL_ADD, fd, nxt_errno);
+ nxt_alert(&engine->task, "epoll_ctl(%d, %d, %d) failed %E",
+ engine->u.epoll.fd, EPOLL_CTL_ADD, fd, nxt_errno);
return NXT_ERROR;
}
@@ -747,8 +742,7 @@ nxt_epoll_signalfd_handler(nxt_task_t *task, void *obj, void *data)
nxt_debug(task, "read signalfd(%d): %d", ev->fd, n);
if (n != sizeof(struct signalfd_siginfo)) {
- nxt_log(task, NXT_LOG_CRIT, "read signalfd(%d) failed %E",
- ev->fd, nxt_errno);
+ nxt_alert(task, "read signalfd(%d) failed %E", ev->fd, nxt_errno);
return;
}
@@ -782,7 +776,7 @@ nxt_epoll_enable_post(nxt_event_engine_t *engine, nxt_work_handler_t handler)
engine->u.epoll.eventfd.fd = eventfd(0, 0);
if (engine->u.epoll.eventfd.fd == -1) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "eventfd() failed %E", nxt_errno);
+ nxt_alert(&engine->task, "eventfd() failed %E", nxt_errno);
return NXT_ERROR;
}
@@ -809,9 +803,9 @@ nxt_epoll_enable_post(nxt_event_engine_t *engine, nxt_work_handler_t handler)
return NXT_OK;
}
- nxt_log(&engine->task, NXT_LOG_CRIT, "epoll_ctl(%d, %d, %d) failed %E",
- engine->u.epoll.fd, EPOLL_CTL_ADD, engine->u.epoll.eventfd.fd,
- nxt_errno);
+ nxt_alert(&engine->task, "epoll_ctl(%d, %d, %d) failed %E",
+ engine->u.epoll.fd, EPOLL_CTL_ADD, engine->u.epoll.eventfd.fd,
+ nxt_errno);
return NXT_ERROR;
}
@@ -846,8 +840,8 @@ nxt_epoll_eventfd_handler(nxt_task_t *task, void *obj, void *data)
engine->u.epoll.eventfd.fd, n, events);
if (n != sizeof(uint64_t)) {
- nxt_log(task, NXT_LOG_CRIT, "read eventfd(%d) failed %E",
- engine->u.epoll.eventfd.fd, nxt_errno);
+ nxt_alert(task, "read eventfd(%d) failed %E",
+ engine->u.epoll.eventfd.fd, nxt_errno);
}
}
@@ -871,8 +865,8 @@ nxt_epoll_signal(nxt_event_engine_t *engine, nxt_uint_t signo)
ret = write(engine->u.epoll.eventfd.fd, &event, sizeof(uint64_t));
if (nxt_slow_path(ret != sizeof(uint64_t))) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "write(%d) to eventfd failed %E",
- engine->u.epoll.eventfd.fd, nxt_errno);
+ nxt_alert(&engine->task, "write(%d) to eventfd failed %E",
+ engine->u.epoll.eventfd.fd, nxt_errno);
}
}
@@ -911,7 +905,7 @@ nxt_epoll_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
nxt_debug(&engine->task, "epoll_wait(%d): %d", engine->u.epoll.fd, nevents);
if (nevents == -1) {
- level = (err == NXT_EINTR) ? NXT_LOG_INFO : NXT_LOG_CRIT;
+ level = (err == NXT_EINTR) ? NXT_LOG_INFO : NXT_LOG_ALERT;
nxt_log(&engine->task, level, "epoll_wait(%d) failed %E",
engine->u.epoll.fd, err);
diff --git a/src/nxt_event_engine.c b/src/nxt_event_engine.c
index 5a52e368..a7166d26 100644
--- a/src/nxt_event_engine.c
+++ b/src/nxt_event_engine.c
@@ -349,8 +349,8 @@ nxt_event_engine_signal_pipe_error(nxt_task_t *task, void *obj, void *data)
engine = task->thread->engine;
pipe = engine->pipe;
- nxt_log(task, NXT_LOG_CRIT, "engine pipe(%FD:%FD) event error",
- pipe->fds[0], pipe->fds[1]);
+ nxt_alert(task, "engine pipe(%FD:%FD) event error",
+ pipe->fds[0], pipe->fds[1]);
nxt_fd_event_close(engine, &pipe->event);
nxt_pipe_close(pipe->event.task, pipe->fds);
@@ -375,8 +375,7 @@ nxt_event_engine_signal_handler(nxt_task_t *task, void *obj, void *data)
}
}
- nxt_log(task, NXT_LOG_CRIT, "signal %ui handler not found",
- (nxt_uint_t) signo);
+ nxt_alert(task, "signal %ui handler not found", (nxt_uint_t) signo);
}
diff --git a/src/nxt_eventport_engine.c b/src/nxt_eventport_engine.c
index 2bf111f9..7ac7f44d 100644
--- a/src/nxt_eventport_engine.c
+++ b/src/nxt_eventport_engine.c
@@ -109,8 +109,7 @@ nxt_eventport_create(nxt_event_engine_t *engine, nxt_uint_t mchanges,
engine->u.eventport.fd = port_create();
if (engine->u.eventport.fd == -1) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "port_create() failed %E",
- nxt_errno);
+ nxt_alert(&engine->task, "port_create() failed %E", nxt_errno);
goto fail;
}
@@ -140,8 +139,8 @@ nxt_eventport_free(nxt_event_engine_t *engine)
nxt_debug(&engine->task, "eventport %d free", port);
if (port != -1 && close(port) != 0) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "eventport close(%d) failed %E",
- port, nxt_errno);
+ nxt_alert(&engine->task, "eventport close(%d) failed %E",
+ port, nxt_errno);
}
nxt_free(engine->u.eventport.events);
@@ -326,9 +325,8 @@ nxt_eventport_commit_changes(nxt_event_engine_t *engine)
goto next;
}
- nxt_log(ev->task, NXT_LOG_CRIT,
- "port_associate(%d, %d, %d, %04XD) failed %E",
- port, PORT_SOURCE_FD, ev->fd, change->events, nxt_errno);
+ nxt_alert(ev->task, "port_associate(%d, %d, %d, %04XD) failed %E",
+ port, PORT_SOURCE_FD, ev->fd, change->events, nxt_errno);
} else {
nxt_debug(ev->task, "port_dissociate(%d): fd:%d", port, ev->fd);
@@ -339,9 +337,8 @@ nxt_eventport_commit_changes(nxt_event_engine_t *engine)
goto next;
}
- nxt_log(ev->task, NXT_LOG_CRIT,
- "port_dissociate(%d, %d, %d) failed %E",
- port, PORT_SOURCE_FD, ev->fd, nxt_errno);
+ nxt_alert(ev->task, "port_dissociate(%d, %d, %d) failed %E",
+ port, PORT_SOURCE_FD, ev->fd, nxt_errno);
}
nxt_work_queue_add(&engine->fast_work_queue,
@@ -445,8 +442,7 @@ nxt_eventport_signal(nxt_event_engine_t *engine, nxt_uint_t signo)
nxt_debug(&engine->task, "port_send(%d, %ui)", port, signo);
if (port_send(port, signo, NULL) != 0) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "port_send(%d) failed %E",
- port, nxt_errno);
+ nxt_alert(&engine->task, "port_send(%d) failed %E", port, nxt_errno);
}
}
@@ -511,14 +507,13 @@ nxt_eventport_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
if (n == -1) {
if (err == NXT_ETIME || err == NXT_EINTR) {
if (nevents != 0) {
- nxt_log(&engine->task, NXT_LOG_CRIT,
- "port_getn(%d) failed %E, events:%ud",
- engine->u.eventport.fd, err, nevents);
+ nxt_alert(&engine->task, "port_getn(%d) failed %E, events:%ud",
+ engine->u.eventport.fd, err, nevents);
}
}
if (err != NXT_ETIME) {
- level = (err == NXT_EINTR) ? NXT_LOG_INFO : NXT_LOG_CRIT;
+ level = (err == NXT_EINTR) ? NXT_LOG_INFO : NXT_LOG_ALERT;
nxt_log(&engine->task, level, "port_getn(%d) failed %E",
engine->u.eventport.fd, err);
@@ -545,9 +540,8 @@ nxt_eventport_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
event->portev_object, events, ev, ev->read, ev->write);
if (nxt_slow_path(events & (POLLERR | POLLHUP | POLLNVAL)) != 0) {
- nxt_log(ev->task, NXT_LOG_CRIT,
- "port_getn(%d) error fd:%d events:%04Xud",
- engine->u.eventport.fd, ev->fd, events);
+ nxt_alert(ev->task, "port_getn(%d) error fd:%d events:%04Xud",
+ engine->u.eventport.fd, ev->fd, events);
nxt_work_queue_add(&engine->fast_work_queue,
nxt_eventport_error_handler,
@@ -608,11 +602,12 @@ nxt_eventport_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
break;
default:
- nxt_log(&engine->task, NXT_LOG_CRIT,
- "unexpected port_getn(%d) event: ev:%d src:%d obj:%p u:%p",
- engine->u.eventport.fd, event->portev_events,
- event->portev_source, event->portev_object,
- event->portev_user);
+ nxt_alert(&engine->task,
+ "unexpected port_getn(%d) event: "
+ "ev:%d src:%d obj:%p u:%p",
+ engine->u.eventport.fd, event->portev_events,
+ event->portev_source, event->portev_object,
+ event->portev_user);
}
}
}
diff --git a/src/nxt_fd_event.c b/src/nxt_fd_event.c
index 11515852..a5e0a3ef 100644
--- a/src/nxt_fd_event.c
+++ b/src/nxt_fd_event.c
@@ -46,7 +46,7 @@ nxt_fd_event_hash_add(nxt_lvlhsh_t *lvlhsh, nxt_fd_t fd, nxt_fd_event_t *ev)
return NXT_OK;
}
- nxt_log(ev->task, NXT_LOG_CRIT, "fd event %d is already in hash", ev->fd);
+ nxt_alert(ev->task, "fd event %d is already in hash", ev->fd);
return NXT_ERROR;
}
@@ -126,5 +126,5 @@ nxt_fd_event_hash_destroy(nxt_lvlhsh_t *lvlhsh)
static void
nxt_fd_event_hash_error(nxt_task_t *task, nxt_fd_t fd)
{
- nxt_log(task, NXT_LOG_CRIT, "fd event %d not found in hash", fd);
+ nxt_alert(task, "fd event %d not found in hash", fd);
}
diff --git a/src/nxt_fiber.c b/src/nxt_fiber.c
index 276e5788..cbb1392b 100644
--- a/src/nxt_fiber.c
+++ b/src/nxt_fiber.c
@@ -133,17 +133,16 @@ nxt_fiber_create_stack(nxt_task_t *task, nxt_fiber_t *fib)
MAP_PRIVATE | MAP_ANON | MAP_GROWSDOWN, -1, 0);
if (nxt_slow_path(s == MAP_FAILED)) {
- nxt_log(task, NXT_LOG_CRIT, "fiber stack "
- "mmap(%uz, MAP_PRIVATE|MAP_ANON|MAP_GROWSDOWN) failed %E",
- size, nxt_errno);
+ nxt_alert(task, "fiber stack "
+ "mmap(%uz, MAP_PRIVATE|MAP_ANON|MAP_GROWSDOWN) failed %E",
+ size, nxt_errno);
return NULL;
}
if (nxt_slow_path(mprotect(s, nxt_pagesize, PROT_NONE) != 0)) {
- nxt_log(task, NXT_LOG_CRIT,
- "fiber stack mprotect(%uz, PROT_NONE) failed %E",
- size, nxt_errno);
+ nxt_alert(task, "fiber stack mprotect(%uz, PROT_NONE) failed %E",
+ size, nxt_errno);
return NULL;
}
@@ -168,17 +167,15 @@ nxt_fiber_create_stack(nxt_task_t *task, nxt_fiber_t *fib)
s = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANON, -1, 0);
if (nxt_slow_path(s == MAP_FAILED)) {
- nxt_log(task, NXT_LOG_CRIT,
- "fiber stack mmap(%uz, MAP_PRIVATE|MAP_ANON) failed %E",
- size, nxt_errno);
+ nxt_alert(task, "fiber stack mmap(%uz, MAP_PRIVATE|MAP_ANON) failed %E",
+ size, nxt_errno);
return NULL;
}
if (nxt_slow_path(mprotect(s, nxt_pagesize, PROT_NONE) != 0)) {
- nxt_log(task, NXT_LOG_CRIT,
- "fiber stack mprotect(%uz, PROT_NONE) failed %E",
- size, nxt_errno);
+ nxt_alert(task, "fiber stack mprotect(%uz, PROT_NONE) failed %E",
+ size, nxt_errno);
return NULL;
}
@@ -212,7 +209,7 @@ nxt_fiber_switch_stack(nxt_fiber_t *fib, jmp_buf *parent)
nxt_debug(&fib->task, "fiber switch to stack: %p", fib->stack);
if (nxt_slow_path(getcontext(&uc) != 0)) {
- nxt_log(&fib->task, NXT_LOG_CRIT, "getcontext() failed");
+ nxt_alert(&fib->task, "getcontext() failed");
return;
}
@@ -228,7 +225,7 @@ nxt_fiber_switch_stack(nxt_fiber_t *fib, jmp_buf *parent)
setcontext(&uc);
- nxt_log(&fib->task, NXT_LOG_CRIT, "setcontext() failed");
+ nxt_alert(&fib->task, "setcontext() failed");
}
@@ -278,7 +275,7 @@ nxt_fiber_switch_stack(nxt_fiber_t *fib, jmp_buf *parent)
nxt_debug(&fib->task, "fiber switch to stack: %p", fib->stack);
if (nxt_slow_path(getcontext(&uc) != 0)) {
- nxt_log(&fib->task, NXT_LOG_CRIT, "getcontext() failed");
+ nxt_alert(&fib->task, "getcontext() failed");
return;
}
@@ -293,7 +290,7 @@ nxt_fiber_switch_stack(nxt_fiber_t *fib, jmp_buf *parent)
#if !(NXT_SOLARIS)
/* Solaris declares setcontext() as __NORETURN. */
- nxt_log(&fib->task, NXT_LOG_CRIT, "setcontext() failed");
+ nxt_alert(&fib->task, "setcontext() failed");
#endif
}
diff --git a/src/nxt_file.c b/src/nxt_file.c
index ce971f82..a9595dd9 100644
--- a/src/nxt_file.c
+++ b/src/nxt_file.c
@@ -48,8 +48,8 @@ nxt_file_close(nxt_task_t *task, nxt_file_t *file)
nxt_debug(task, "close(%FD)", file->fd);
if (close(file->fd) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "close(%FD, \"%FN\") failed %E",
- file->fd, file->name, nxt_errno);
+ nxt_alert(task, "close(%FD, \"%FN\") failed %E",
+ file->fd, file->name, nxt_errno);
}
}
@@ -75,8 +75,7 @@ nxt_file_write(nxt_file_t *file, const u_char *buf, size_t size,
return n;
}
- nxt_thread_log_error(NXT_LOG_CRIT,
- "pwrite(%FD, \"%FN\", %p, %uz, %O) failed %E",
+ nxt_thread_log_alert("pwrite(%FD, \"%FN\", %p, %uz, %O) failed %E",
file->fd, file->name, buf, size,
offset, file->error);
@@ -104,8 +103,7 @@ nxt_file_read(nxt_file_t *file, u_char *buf, size_t size, nxt_off_t offset)
return n;
}
- nxt_thread_log_error(NXT_LOG_CRIT,
- "pread(%FD, \"%FN\", %p, %uz, %O) failed %E",
+ nxt_thread_log_alert("pread(%FD, \"%FN\", %p, %uz, %O) failed %E",
file->fd, file->name, buf, size,
offset, file->error);
@@ -133,8 +131,7 @@ nxt_file_read_ahead(nxt_file_t *file, nxt_off_t offset, size_t size)
return;
}
- nxt_thread_log_error(NXT_LOG_CRIT,
- "fcntl(%FD, \"%FN\", F_READAHEAD, %uz) failed %E",
+ nxt_thread_log_alert("fcntl(%FD, \"%FN\", F_READAHEAD, %uz) failed %E",
file->fd, file->name, size, nxt_errno);
}
@@ -171,8 +168,7 @@ nxt_file_read_ahead(nxt_file_t *file, nxt_off_t offset, size_t size)
return;
}
- nxt_thread_log_error(NXT_LOG_CRIT,
- "posix_fadvise(%FD, \"%FN\", %O, %uz, %d) failed %E",
+ nxt_thread_log_alert("posix_fadvise(%FD, \"%FN\", %O, %uz, %d) failed %E",
file->fd, file->name, offset, size,
POSIX_FADV_WILLNEED, err);
}
@@ -196,8 +192,7 @@ nxt_file_read_ahead(nxt_file_t *file, nxt_off_t offset, size_t size)
return;
}
- nxt_thread_log_error(NXT_LOG_CRIT,
- "fcntl(%FD, \"%FN\", F_RDAHEAD, 1) failed %E",
+ nxt_thread_log_alert("fcntl(%FD, \"%FN\", F_RDAHEAD, 1) failed %E",
file->fd, file->name, nxt_errno);
}
@@ -248,9 +243,9 @@ nxt_file_info(nxt_file_t *file, nxt_file_info_t *fi)
return NXT_OK;
}
- /* Use NXT_LOG_CRIT because fstat() error on open file is strange. */
+ /* Use NXT_LOG_ALERT because fstat() error on open file is strange. */
- nxt_thread_log_error(NXT_LOG_CRIT, "fstat(%FD, \"%FN\") failed %E",
+ nxt_thread_log_alert("fstat(%FD, \"%FN\") failed %E",
file->fd, file->name, file->error);
return NXT_ERROR;
@@ -330,7 +325,7 @@ nxt_fd_nonblocking(nxt_task_t *task, nxt_fd_t fd)
return NXT_OK;
}
- nxt_log(task, NXT_LOG_CRIT, "ioctl(%d, FIONBIO) failed %E", fd, nxt_errno);
+ nxt_alert(task, "ioctl(%d, FIONBIO) failed %E", fd, nxt_errno);
return NXT_ERROR;
@@ -348,7 +343,7 @@ nxt_fd_blocking(nxt_task_t *task, nxt_fd_t fd)
return NXT_OK;
}
- nxt_log(task, NXT_LOG_CRIT, "ioctl(%d, !FIONBIO) failed %E", fd, nxt_errno);
+ nxt_alert(task, "ioctl(%d, !FIONBIO) failed %E", fd, nxt_errno);
return NXT_ERROR;
}
@@ -363,16 +358,15 @@ nxt_fd_nonblocking(nxt_task_t *task, nxt_fd_t fd)
flags = fcntl(fd, F_GETFL);
if (nxt_slow_path(flags == -1)) {
- nxt_log(task, NXT_LOG_CRIT, "fcntl(%d, F_GETFL) failed %E",
- fd, nxt_errno);
+ nxt_alert(task, "fcntl(%d, F_GETFL) failed %E", fd, nxt_errno);
return NXT_ERROR;
}
flags |= O_NONBLOCK;
if (nxt_slow_path(fcntl(fd, F_SETFL, flags) == -1)) {
- nxt_log(task, NXT_LOG_CRIT, "fcntl(%d, F_SETFL, O_NONBLOCK) failed %E",
- fd, nxt_errno);
+ nxt_alert(task, "fcntl(%d, F_SETFL, O_NONBLOCK) failed %E",
+ fd, nxt_errno);
return NXT_ERROR;
}
@@ -388,16 +382,15 @@ nxt_fd_blocking(nxt_task_t *task, nxt_fd_t fd)
flags = fcntl(fd, F_GETFL);
if (nxt_slow_path(flags == -1)) {
- nxt_log(task, NXT_LOG_CRIT, "fcntl(%d, F_GETFL) failed %E",
- fd, nxt_errno);
+ nxt_alert(task, "fcntl(%d, F_GETFL) failed %E", fd, nxt_errno);
return NXT_ERROR;
}
flags &= O_NONBLOCK;
if (nxt_slow_path(fcntl(fd, F_SETFL, flags) == -1)) {
- nxt_log(task, NXT_LOG_CRIT, "fcntl(%d, F_SETFL, !O_NONBLOCK) failed %E",
- fd, nxt_errno);
+ nxt_alert(task, "fcntl(%d, F_SETFL, !O_NONBLOCK) failed %E",
+ fd, nxt_errno);
return NXT_ERROR;
}
@@ -458,8 +451,7 @@ nxt_fd_close(nxt_fd_t fd)
nxt_thread_log_debug("close(%FD)", fd);
if (nxt_slow_path(close(fd) != 0)) {
- nxt_thread_log_error(NXT_LOG_CRIT, "close(%FD) failed %E",
- fd, nxt_errno);
+ nxt_thread_log_alert("close(%FD) failed %E", fd, nxt_errno);
}
}
@@ -475,13 +467,13 @@ nxt_file_redirect(nxt_file_t *file, nxt_fd_t fd)
nxt_thread_log_debug("dup2(%FD, %FD, \"%FN\")", fd, file->fd, file->name);
if (dup2(fd, file->fd) == -1) {
- nxt_thread_log_error(NXT_LOG_CRIT, "dup2(%FD, %FD, \"%FN\") failed %E",
+ nxt_thread_log_alert("dup2(%FD, %FD, \"%FN\") failed %E",
fd, file->fd, file->name, nxt_errno);
return NXT_ERROR;
}
if (close(fd) != 0) {
- nxt_thread_log_error(NXT_LOG_CRIT, "close(%FD, \"%FN\") failed %E",
+ nxt_thread_log_alert("close(%FD, \"%FN\") failed %E",
fd, file->name, nxt_errno);
return NXT_ERROR;
}
@@ -502,7 +494,7 @@ nxt_file_stderr(nxt_file_t *file)
return NXT_OK;
}
- nxt_thread_log_error(NXT_LOG_CRIT, "dup2(%FD, %FD, \"%FN\") failed %E",
+ nxt_thread_log_alert("dup2(%FD, %FD, \"%FN\") failed %E",
file->fd, STDERR_FILENO, file->name, nxt_errno);
return NXT_ERROR;
@@ -552,7 +544,7 @@ nxt_pipe_create(nxt_task_t *task, nxt_fd_t *pp, nxt_bool_t nbread,
nxt_bool_t nbwrite)
{
if (pipe(pp) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "pipe() failed %E", nxt_errno);
+ nxt_alert(task, "pipe() failed %E", nxt_errno);
return NXT_ERROR;
}
@@ -581,13 +573,11 @@ nxt_pipe_close(nxt_task_t *task, nxt_fd_t *pp)
nxt_debug(task, "pipe close(%FD:%FD)", pp[0], pp[1]);
if (close(pp[0]) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "pipe close(%FD) failed %E",
- pp[0], nxt_errno);
+ nxt_alert(task, "pipe close(%FD) failed %E", pp[0], nxt_errno);
}
if (close(pp[1]) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "pipe close(%FD) failed %E",
- pp[1], nxt_errno);
+ nxt_alert(task, "pipe close(%FD) failed %E", pp[1], nxt_errno);
}
}
diff --git a/src/nxt_file.h b/src/nxt_file.h
index 4b8e5684..5216fb1c 100644
--- a/src/nxt_file.h
+++ b/src/nxt_file.h
@@ -97,7 +97,7 @@ typedef struct {
/*
* Log open() file error with given log level if it is non zero.
- * Note that zero log level is NXT_LOG_EMERG.
+ * Note that zero log level is NXT_LOG_ALERT.
*/
uint8_t log_level;
diff --git a/src/nxt_gnutls.c b/src/nxt_gnutls.c
index 2db43d4a..4618dce9 100644
--- a/src/nxt_gnutls.c
+++ b/src/nxt_gnutls.c
@@ -99,7 +99,7 @@ nxt_gnutls_start(void)
ret = gnutls_global_init();
if (ret != GNUTLS_E_SUCCESS) {
- nxt_gnutls_log_error(NXT_LOG_CRIT, nxt_thread_log(), ret,
+ nxt_gnutls_log_error(NXT_LOG_ALERT, nxt_thread_log(), ret,
"gnutls_global_init() failed");
return NXT_ERROR;
}
@@ -167,7 +167,7 @@ nxt_gnutls_server_init(nxt_ssltls_conf_t *conf)
ret = gnutls_certificate_allocate_credentials(&ctx->certificate);
if (ret != GNUTLS_E_SUCCESS) {
- nxt_gnutls_log_error(NXT_LOG_CRIT, thr->log, ret,
+ nxt_gnutls_log_error(NXT_LOG_ALERT, thr->log, ret,
"gnutls_certificate_allocate_credentials() failed");
return NXT_ERROR;
}
@@ -178,7 +178,7 @@ nxt_gnutls_server_init(nxt_ssltls_conf_t *conf)
ret = gnutls_certificate_set_x509_key_file(ctx->certificate, certificate,
key, GNUTLS_X509_FMT_PEM);
if (ret != GNUTLS_E_SUCCESS) {
- nxt_gnutls_log_error(NXT_LOG_CRIT, thr->log, ret,
+ nxt_gnutls_log_error(NXT_LOG_ALERT, thr->log, ret,
"gnutls_certificate_set_x509_key_file(\"%s\", \"%s\") failed",
certificate, key);
goto certificate_fail;
@@ -195,7 +195,7 @@ nxt_gnutls_server_init(nxt_ssltls_conf_t *conf)
ca_certificate,
GNUTLS_X509_FMT_PEM);
if (ret < 0) {
- nxt_gnutls_log_error(NXT_LOG_CRIT, thr->log, ret,
+ nxt_gnutls_log_error(NXT_LOG_ALERT, thr->log, ret,
"gnutls_certificate_set_x509_trust_file(\"%s\") failed",
ca_certificate);
goto ca_certificate_fail;
@@ -237,13 +237,13 @@ nxt_gnutls_set_ciphers(nxt_ssltls_conf_t *conf)
return NXT_OK;
case GNUTLS_E_INVALID_REQUEST:
- nxt_gnutls_log_error(NXT_LOG_CRIT, nxt_thread_log(), ret,
+ nxt_gnutls_log_error(NXT_LOG_ALERT, nxt_thread_log(), ret,
"gnutls_priority_init(\"%s\") failed at \"%s\"",
ciphers, err);
return NXT_ERROR;
default:
- nxt_gnutls_log_error(NXT_LOG_CRIT, nxt_thread_log(), ret,
+ nxt_gnutls_log_error(NXT_LOG_ALERT, nxt_thread_log(), ret,
"gnutls_priority_init() failed");
return NXT_ERROR;
}
@@ -277,7 +277,7 @@ nxt_gnutls_conn_init(nxt_thread_t *thr, nxt_ssltls_conf_t *conf,
ret = gnutls_init(&ssltls->session, GNUTLS_SERVER);
if (ret != GNUTLS_E_SUCCESS) {
- nxt_gnutls_log_error(NXT_LOG_CRIT, c->socket.log, ret,
+ nxt_gnutls_log_error(NXT_LOG_ALERT, c->socket.log, ret,
"gnutls_init() failed");
goto fail;
}
@@ -290,7 +290,7 @@ nxt_gnutls_conn_init(nxt_thread_t *thr, nxt_ssltls_conf_t *conf,
ret = gnutls_priority_set(sess, ctx->ciphers);
if (ret != GNUTLS_E_SUCCESS) {
- nxt_gnutls_log_error(NXT_LOG_CRIT, c->socket.log, ret,
+ nxt_gnutls_log_error(NXT_LOG_ALERT, c->socket.log, ret,
"gnutls_priority_set() failed");
goto fail;
}
@@ -304,7 +304,7 @@ nxt_gnutls_conn_init(nxt_thread_t *thr, nxt_ssltls_conf_t *conf,
ret = gnutls_credentials_set(sess, GNUTLS_CRD_CERTIFICATE,
ctx->certificate);
if (ret != GNUTLS_E_SUCCESS) {
- nxt_gnutls_log_error(NXT_LOG_CRIT, c->socket.log, ret,
+ nxt_gnutls_log_error(NXT_LOG_ALERT, c->socket.log, ret,
"gnutls_credentials_set() failed");
goto fail;
}
@@ -719,7 +719,7 @@ nxt_gnutls_log_error_level(nxt_event_conn_t *c, ssize_t err)
break;
default:
- return NXT_LOG_CRIT;
+ return NXT_LOG_ALERT;
}
return NXT_LOG_INFO;
diff --git a/src/nxt_go.c b/src/nxt_go.c
index 294c608b..709908e2 100644
--- a/src/nxt_go.c
+++ b/src/nxt_go.c
@@ -38,8 +38,7 @@ nxt_go_fd_no_cloexec(nxt_task_t *task, nxt_socket_t fd)
flags = fcntl(fd, F_GETFD);
if (nxt_slow_path(flags == -1)) {
- nxt_log(task, NXT_LOG_CRIT, "fcntl(%d, F_GETFD) failed %E",
- fd, nxt_errno);
+ nxt_alert(task, "fcntl(%d, F_GETFD) failed %E", fd, nxt_errno);
return NXT_ERROR;
}
@@ -48,8 +47,7 @@ nxt_go_fd_no_cloexec(nxt_task_t *task, nxt_socket_t fd)
res = fcntl(fd, F_SETFD, flags);
if (nxt_slow_path(res == -1)) {
- nxt_log(task, NXT_LOG_CRIT, "fcntl(%d, F_SETFD) failed %E",
- fd, nxt_errno);
+ nxt_alert(task, "fcntl(%d, F_SETFD) failed %E", fd, nxt_errno);
return NXT_ERROR;
}
@@ -100,8 +98,7 @@ nxt_go_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
my_port->pair[0], -1);
if (nxt_slow_path(p == end)) {
- nxt_log(task, NXT_LOG_ALERT,
- "internal error: buffer too small for NXT_GO_PORTS");
+ nxt_alert(task, "internal error: buffer too small for NXT_GO_PORTS");
return NXT_ERROR;
}
@@ -110,8 +107,7 @@ nxt_go_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
rc = setenv("NXT_GO_PORTS", (char *) buf, 1);
if (nxt_slow_path(rc == -1)) {
- nxt_log(task, NXT_LOG_CRIT, "setenv(NXT_GO_PORTS, %s) failed %E",
- buf, nxt_errno);
+ nxt_alert(task, "setenv(NXT_GO_PORTS, %s) failed %E", buf, nxt_errno);
return NXT_ERROR;
}
@@ -123,8 +119,7 @@ nxt_go_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
(void) execve(c->executable, argv, environ);
- nxt_log(task, NXT_LOG_CRIT, "execve(%s) failed %E",
- c->executable, nxt_errno);
+ nxt_alert(task, "execve(%s) failed %E", c->executable, nxt_errno);
return NXT_ERROR;
}
diff --git a/src/nxt_kqueue_engine.c b/src/nxt_kqueue_engine.c
index c8585063..378a2e04 100644
--- a/src/nxt_kqueue_engine.c
+++ b/src/nxt_kqueue_engine.c
@@ -194,7 +194,7 @@ nxt_kqueue_create(nxt_event_engine_t *engine, nxt_uint_t mchanges,
engine->u.kqueue.fd = kqueue();
if (engine->u.kqueue.fd == -1) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "kqueue() failed %E", nxt_errno);
+ nxt_alert(&engine->task, "kqueue() failed %E", nxt_errno);
goto fail;
}
@@ -231,8 +231,8 @@ nxt_kqueue_free(nxt_event_engine_t *engine)
/* kqueue is not inherited by fork() */
if (close(fd) != 0) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "kqueue close(%d) failed %E",
- fd, nxt_errno);
+ nxt_alert(&engine->task, "kqueue close(%d) failed %E",
+ fd, nxt_errno);
}
}
@@ -478,8 +478,8 @@ nxt_kqueue_get_kevent(nxt_event_engine_t *engine)
NULL, 0, NULL);
if (nxt_slow_path(ret != 0)) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "kevent(%d) failed %E",
- engine->u.kqueue.fd, nxt_errno);
+ nxt_alert(&engine->task, "kevent(%d) failed %E",
+ engine->u.kqueue.fd, nxt_errno);
nxt_kqueue_error(engine);
}
@@ -581,8 +581,7 @@ nxt_kqueue_add_signal(nxt_event_engine_t *engine, const nxt_sig_event_t *sigev)
sa.sa_handler = (signo == SIGCHLD) ? SIG_DFL : SIG_IGN;
if (sigaction(signo, &sa, NULL) != 0) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "sigaction(%d) failed %E",
- signo, nxt_errno);
+ nxt_alert(&engine->task, "sigaction(%d) failed %E", signo, nxt_errno);
return NXT_ERROR;
}
@@ -601,8 +600,7 @@ nxt_kqueue_add_signal(nxt_event_engine_t *engine, const nxt_sig_event_t *sigev)
return NXT_OK;
}
- nxt_log(&engine->task, NXT_LOG_CRIT, "kevent(%d) failed %E",
- kqueue, nxt_errno);
+ nxt_alert(&engine->task, "kevent(%d) failed %E", kqueue, nxt_errno);
return NXT_ERROR;
}
@@ -630,8 +628,8 @@ nxt_kqueue_enable_post(nxt_event_engine_t *engine, nxt_work_handler_t handler)
return NXT_OK;
}
- nxt_log(&engine->task, NXT_LOG_CRIT, "kevent(%d) failed %E",
- engine->u.kqueue.fd, nxt_errno);
+ nxt_alert(&engine->task, "kevent(%d) failed %E",
+ engine->u.kqueue.fd, nxt_errno);
return NXT_ERROR;
}
@@ -655,8 +653,8 @@ nxt_kqueue_signal(nxt_event_engine_t *engine, nxt_uint_t signo)
kev.udata = NULL;
if (kevent(engine->u.kqueue.fd, &kev, 1, NULL, 0, NULL) != 0) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "kevent(%d) failed %E",
- engine->u.kqueue.fd, nxt_errno);
+ nxt_alert(&engine->task, "kevent(%d) failed %E",
+ engine->u.kqueue.fd, nxt_errno);
}
}
@@ -704,7 +702,7 @@ nxt_kqueue_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
nxt_debug(&engine->task, "kevent(%d): %d", engine->u.kqueue.fd, nevents);
if (nevents == -1) {
- level = (err == NXT_EINTR) ? NXT_LOG_INFO : NXT_LOG_CRIT;
+ level = (err == NXT_EINTR) ? NXT_LOG_INFO : NXT_LOG_ALERT;
nxt_log(&engine->task, level, "kevent(%d) failed %E",
engine->u.kqueue.fd, err);
@@ -729,9 +727,9 @@ nxt_kqueue_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
error = (kev->flags & EV_ERROR);
if (nxt_slow_path(error)) {
- nxt_log(&engine->task, NXT_LOG_CRIT,
- "kevent(%d) error %E on ident:%d filter:%d",
- engine->u.kqueue.fd, kev->data, kev->ident, kev->filter);
+ nxt_alert(&engine->task,
+ "kevent(%d) error %E on ident:%d filter:%d",
+ engine->u.kqueue.fd, kev->data, kev->ident, kev->filter);
}
task = &engine->task;
@@ -830,9 +828,9 @@ nxt_kqueue_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
default:
#if (NXT_DEBUG)
- nxt_log(&engine->task, NXT_LOG_CRIT,
- "unexpected kevent(%d) filter %d on ident %d",
- engine->u.kqueue.fd, kev->filter, kev->ident);
+ nxt_alert(&engine->task,
+ "unexpected kevent(%d) filter %d on ident %d",
+ engine->u.kqueue.fd, kev->filter, kev->ident);
#endif
continue;
diff --git a/src/nxt_listen_socket.c b/src/nxt_listen_socket.c
index 70c57746..a99bc630 100644
--- a/src/nxt_listen_socket.c
+++ b/src/nxt_listen_socket.c
@@ -20,8 +20,7 @@ nxt_listen_socket(nxt_task_t *task, nxt_socket_t s, int backlog)
return NXT_OK;
}
- nxt_log(task, NXT_LOG_CRIT, "listen(%d, %d) failed %E",
- s, backlog, nxt_socket_errno);
+ nxt_alert(task, "listen(%d, %d) failed %E", s, backlog, nxt_socket_errno);
return NXT_ERROR;
}
@@ -118,8 +117,8 @@ nxt_listen_socket_create(nxt_task_t *task, nxt_listen_socket_t *ls,
nxt_debug(task, "listen(%d, %d)", s, ls->backlog);
if (listen(s, ls->backlog) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "listen(%d, %d) failed %E",
- s, ls->backlog, nxt_socket_errno);
+ nxt_alert(task, "listen(%d, %d) failed %E",
+ s, ls->backlog, nxt_socket_errno);
goto fail;
}
@@ -159,8 +158,8 @@ nxt_listen_socket_update(nxt_task_t *task, nxt_listen_socket_t *ls,
nxt_debug(task, "listen(%d, %d)", ls->socket, ls->backlog);
if (listen(ls->socket, ls->backlog) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "listen(%d, %d) failed %E",
- ls->socket, ls->backlog, nxt_socket_errno);
+ nxt_alert(task, "listen(%d, %d) failed %E",
+ ls->socket, ls->backlog, nxt_socket_errno);
goto fail;
}
diff --git a/src/nxt_log.c b/src/nxt_log.c
index cd2b5d70..992c3205 100644
--- a/src/nxt_log.c
+++ b/src/nxt_log.c
@@ -20,10 +20,8 @@ nxt_log_t nxt_main_log = {
};
-nxt_str_t nxt_log_levels[8] = {
- nxt_string("emerg"),
+nxt_str_t nxt_log_levels[6] = {
nxt_string("alert"),
- nxt_string("crit"),
nxt_string("error"),
nxt_string("warn"),
nxt_string("notice"),
@@ -102,7 +100,7 @@ nxt_log_handler(nxt_uint_t level, nxt_log_t *log, const char *fmt, ...)
(void) nxt_write_console(nxt_stderr, msg, p - msg);
- if (level <= NXT_LOG_ALERT) {
+ if (level == NXT_LOG_ALERT) {
*(p - NXT_LINEFEED_SIZE) = '\0';
/*
diff --git a/src/nxt_log.h b/src/nxt_log.h
index f5e60129..48742721 100644
--- a/src/nxt_log.h
+++ b/src/nxt_log.h
@@ -8,14 +8,12 @@
#define _NXT_LOG_H_INCLUDED_
-#define NXT_LOG_EMERG 0
-#define NXT_LOG_ALERT 1
-#define NXT_LOG_CRIT 2
-#define NXT_LOG_ERR 3
-#define NXT_LOG_WARN 4
-#define NXT_LOG_NOTICE 5
-#define NXT_LOG_INFO 6
-#define NXT_LOG_DEBUG 7
+#define NXT_LOG_ALERT 0
+#define NXT_LOG_ERR 1
+#define NXT_LOG_WARN 2
+#define NXT_LOG_NOTICE 3
+#define NXT_LOG_INFO 4
+#define NXT_LOG_DEBUG 5
#define NXT_MAX_ERROR_STR 2048
@@ -48,21 +46,11 @@ nxt_log_level_enough(log, level) \
((log)->level >= (level))
-#define \
-nxt_log_emerg(_log, ...) \
+#define nxt_alert(task, ...) \
do { \
- nxt_log_t *_log_ = (_log); \
- \
- _log_->handler(NXT_LOG_EMERG, _log_, __VA_ARGS__); \
- } while (0)
-
-
-#define \
-nxt_log_alert(_log, ...) \
- do { \
- nxt_log_t *_log_ = (_log); \
+ nxt_log_t *log = (task)->log; \
\
- _log_->handler(NXT_LOG_ALERT, _log_, __VA_ARGS__); \
+ log->handler(NXT_LOG_ALERT, log, __VA_ARGS__); \
} while (0)
@@ -87,6 +75,14 @@ nxt_log_alert(_log, ...) \
} while (0)
+#define nxt_log_alert(_log, ...) \
+ do { \
+ nxt_log_t *_log_ = (_log); \
+ \
+ _log_->handler(NXT_LOG_ALERT, _log_, __VA_ARGS__); \
+ } while (0)
+
+
#define \
nxt_log_error(_level, _log, ...) \
do { \
@@ -156,11 +152,6 @@ nxt_log_debug(...)
#define \
-nxt_main_log_emerg(...) \
- nxt_log_emerg(&nxt_main_log, __VA_ARGS__)
-
-
-#define \
nxt_main_log_alert(...) \
nxt_log_alert(&nxt_main_log, __VA_ARGS__)
diff --git a/src/nxt_log_moderation.h b/src/nxt_log_moderation.h
index ebef7fd5..0a53594d 100644
--- a/src/nxt_log_moderation.h
+++ b/src/nxt_log_moderation.h
@@ -24,6 +24,17 @@ typedef struct {
#define \
+nxt_log_alert_moderate(_mod, _log, ...) \
+ do { \
+ nxt_log_t *_log_ = _log; \
+ \
+ if (nxt_log_moderate_allow(_mod)) { \
+ _log_->handler(NXT_LOG_ALERT, _log_, __VA_ARGS__); \
+ } \
+ } while (0)
+
+
+#define \
nxt_log_moderate(_mod, _level, _log, ...) \
do { \
nxt_log_t *_log_ = _log; \
diff --git a/src/nxt_main_process.c b/src/nxt_main_process.c
index 27bf01f5..f1f5d6d4 100644
--- a/src/nxt_main_process.c
+++ b/src/nxt_main_process.c
@@ -242,7 +242,7 @@ nxt_port_main_start_worker_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
conf = nxt_conf_json_parse(mp, start, b->mem.free, NULL);
if (conf == NULL) {
- nxt_log(task, NXT_LOG_ALERT, "router app configuration parsing error");
+ nxt_alert(task, "router app configuration parsing error");
goto failed;
}
@@ -252,8 +252,7 @@ nxt_port_main_start_worker_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
ret = nxt_conf_map_object(mp, conf, nxt_common_app_conf,
nxt_nitems(nxt_common_app_conf), &app_conf);
if (ret != NXT_OK) {
- nxt_log(task, NXT_LOG_ALERT,
- "failed to map common app conf received from router");
+ nxt_alert(task, "failed to map common app conf received from router");
goto failed;
}
@@ -268,8 +267,7 @@ nxt_port_main_start_worker_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
idx = nxt_app_parse_type(app_conf.type.start, type_len);
if (nxt_slow_path(idx >= nxt_nitems(nxt_app_maps))) {
- nxt_log(task, NXT_LOG_ALERT,
- "invalid app type %d received from router", (int) idx);
+ nxt_alert(task, "invalid app type %d received from router", (int) idx);
goto failed;
}
@@ -277,8 +275,7 @@ nxt_port_main_start_worker_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
nxt_app_maps[idx].size, &app_conf);
if (nxt_slow_path(ret != NXT_OK)) {
- nxt_log(task, NXT_LOG_ALERT,
- "failed to map app conf received from router");
+ nxt_alert(task, "failed to map app conf received from router");
goto failed;
}
@@ -440,9 +437,8 @@ nxt_main_create_controller_process(nxt_task_t *task, nxt_runtime_t *rt,
conf.length = 0;
nxt_free(conf.start);
- nxt_log(task, NXT_LOG_ALERT,
- "failed to restore previous configuration: "
- "cannot read the file");
+ nxt_alert(task, "failed to restore previous configuration: "
+ "cannot read the file");
}
}
@@ -718,7 +714,7 @@ nxt_main_process_sigusr1_handler(nxt_task_t *task, void *obj, void *data)
new_file->name = file->name;
new_file->fd = NXT_FILE_INVALID;
- new_file->log_level = NXT_LOG_CRIT;
+ new_file->log_level = NXT_LOG_ALERT;
ret = nxt_file_open(task, new_file, O_WRONLY | O_APPEND, O_CREAT,
NXT_FILE_OWNER_ACCESS);
@@ -797,7 +793,7 @@ nxt_main_process_sigchld_handler(nxt_task_t *task, void *obj, void *data)
continue;
default:
- nxt_log(task, NXT_LOG_CRIT, "waitpid() failed: %E", err);
+ nxt_alert(task, "waitpid() failed: %E", err);
return;
}
}
@@ -810,12 +806,12 @@ nxt_main_process_sigchld_handler(nxt_task_t *task, void *obj, void *data)
if (WTERMSIG(status)) {
#ifdef WCOREDUMP
- nxt_log(task, NXT_LOG_CRIT, "process %PI exited on signal %d%s",
- pid, WTERMSIG(status),
- WCOREDUMP(status) ? " (core dumped)" : "");
+ nxt_alert(task, "process %PI exited on signal %d%s",
+ pid, WTERMSIG(status),
+ WCOREDUMP(status) ? " (core dumped)" : "");
#else
- nxt_log(task, NXT_LOG_CRIT, "process %PI exited on signal %d",
- pid, WTERMSIG(status));
+ nxt_alert(task, "process %PI exited on signal %d",
+ pid, WTERMSIG(status));
#endif
} else {
@@ -937,7 +933,7 @@ nxt_main_port_socket_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
} else {
size = ls.end - ls.start;
- nxt_log(task, NXT_LOG_CRIT, "%*s", size, ls.start);
+ nxt_alert(task, "%*s", size, ls.start);
out = nxt_buf_mem_ts_alloc(task, task->thread->engine->mem_pool,
size + 1);
@@ -1274,5 +1270,5 @@ nxt_main_port_conf_store_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
error:
- nxt_log(task, NXT_LOG_ALERT, "failed to store current configuration");
+ nxt_alert(task, "failed to store current configuration");
}
diff --git a/src/nxt_malloc.c b/src/nxt_malloc.c
index 568f04c6..910ef7cd 100644
--- a/src/nxt_malloc.c
+++ b/src/nxt_malloc.c
@@ -38,9 +38,8 @@ nxt_malloc(size_t size)
nxt_log_debug(nxt_malloc_log(), "malloc(%uz): %p", size, p);
} else {
- nxt_log_moderate(&nxt_malloc_log_moderation,
- NXT_LOG_ALERT, nxt_malloc_log(),
- "malloc(%uz) failed %E", size, nxt_errno);
+ nxt_log_alert_moderate(&nxt_malloc_log_moderation, nxt_malloc_log(),
+ "malloc(%uz) failed %E", size, nxt_errno);
}
return p;
@@ -73,9 +72,9 @@ nxt_realloc(void *p, size_t size)
nxt_log_debug(nxt_malloc_log(), "realloc(%p, %uz): %p", p, size, n);
} else {
- nxt_log_moderate(&nxt_malloc_log_moderation,
- NXT_LOG_ALERT, nxt_malloc_log(),
- "realloc(%p, %uz) failed %E", p, size, nxt_errno);
+ nxt_log_alert_moderate(&nxt_malloc_log_moderation, nxt_malloc_log(),
+ "realloc(%p, %uz) failed %E",
+ p, size, nxt_errno);
}
return n;
@@ -117,10 +116,9 @@ nxt_memalign(size_t alignment, size_t size)
return p;
}
- nxt_log_moderate(&nxt_malloc_log_moderation,
- NXT_LOG_ALERT, nxt_malloc_log(),
- "posix_memalign(%uz, %uz) failed %E",
- alignment, size, err);
+ nxt_log_alert_moderate(&nxt_malloc_log_moderation, nxt_malloc_log(),
+ "posix_memalign(%uz, %uz) failed %E",
+ alignment, size, err);
return NULL;
}
@@ -141,10 +139,9 @@ nxt_memalign(size_t alignment, size_t size)
return p;
}
- nxt_log_moderate(&nxt_malloc_log_moderation,
- NXT_LOG_ALERT, nxt_malloc_log(),
- "memalign(%uz, %uz) failed %E",
- alignment, size, nxt_errno);
+ nxt_log_alert_moderate(&nxt_malloc_log_moderation, nxt_malloc_log(),
+ "memalign(%uz, %uz) failed %E",
+ alignment, size, nxt_errno);
return NULL;
}
@@ -189,9 +186,8 @@ nxt_memalign(size_t alignment, size_t size)
nxt_thread_log_debug("nxt_memalign(%uz, %uz): %p", alignment, size, p);
} else {
- nxt_log_moderate(&nxt_malloc_log_moderation,
- NXT_LOG_ALERT, nxt_malloc_log(),
- "malloc(%uz) failed %E", size, nxt_errno);
+ nxt_log_alert_moderate(&nxt_malloc_log_moderation, nxt_malloc_log(),
+ "malloc(%uz) failed %E", size, nxt_errno);
}
return p;
diff --git a/src/nxt_mem_zone.c b/src/nxt_mem_zone.c
index 9214a422..a93441c5 100644
--- a/src/nxt_mem_zone.c
+++ b/src/nxt_mem_zone.c
@@ -503,8 +503,7 @@ nxt_mem_zone_align(nxt_mem_zone_t *zone, size_t alignment, size_t size)
nxt_thread_log_debug("mem zone alloc: %p", p);
} else {
- nxt_log_moderate(&nxt_mem_zone_log_moderation,
- NXT_LOG_ALERT, nxt_thread_log(),
+ nxt_log_alert_moderate(&nxt_mem_zone_log_moderation, nxt_thread_log(),
"nxt_mem_zone_alloc(%uz, %uz) failed, not enough memory",
alignment, size);
}
diff --git a/src/nxt_mp.c b/src/nxt_mp.c
index 776c96b2..43c0a2c0 100644
--- a/src/nxt_mp.c
+++ b/src/nxt_mp.c
@@ -772,7 +772,6 @@ void
nxt_mp_free(nxt_mp_t *mp, void *p)
{
const char *err;
- nxt_thread_t *thread;
nxt_mp_block_t *block;
nxt_mp_thread_assert(mp);
@@ -809,9 +808,7 @@ nxt_mp_free(nxt_mp_t *mp, void *p)
err = "freed pointer is out of pool: %p";
}
- thread = nxt_thread();
-
- nxt_log(thread->task, NXT_LOG_CRIT, err, p);
+ nxt_thread_log_alert(err, p);
}
diff --git a/src/nxt_openssl.c b/src/nxt_openssl.c
index c5f33504..d8c892dd 100644
--- a/src/nxt_openssl.c
+++ b/src/nxt_openssl.c
@@ -116,7 +116,7 @@ nxt_openssl_start(nxt_thread_t *thr)
index = SSL_get_ex_new_index(0, NULL, NULL, NULL, NULL);
if (index == -1) {
- nxt_openssl_log_error(NXT_LOG_CRIT, thr->log,
+ nxt_openssl_log_error(NXT_LOG_ALERT, thr->log,
"SSL_get_ex_new_index() failed");
return NXT_ERROR;
}
@@ -143,7 +143,7 @@ nxt_openssl_server_init(nxt_ssltls_conf_t *conf)
ctx = SSL_CTX_new(SSLv23_server_method());
if (ctx == NULL) {
- nxt_openssl_log_error(NXT_LOG_CRIT, thr->log, "SSL_CTX_new() failed");
+ nxt_openssl_log_error(NXT_LOG_ALERT, thr->log, "SSL_CTX_new() failed");
return NXT_ERROR;
}
@@ -174,7 +174,7 @@ nxt_openssl_server_init(nxt_ssltls_conf_t *conf)
certificate = conf->certificate;
if (SSL_CTX_use_certificate_chain_file(ctx, certificate) == 0) {
- nxt_openssl_log_error(NXT_LOG_CRIT, thr->log,
+ nxt_openssl_log_error(NXT_LOG_ALERT, thr->log,
"SSL_CTX_use_certificate_file(\"%s\") failed",
certificate);
goto fail;
@@ -183,7 +183,7 @@ nxt_openssl_server_init(nxt_ssltls_conf_t *conf)
key = conf->certificate_key;
if (SSL_CTX_use_PrivateKey_file(ctx, key, SSL_FILETYPE_PEM) == 0) {
- nxt_openssl_log_error(NXT_LOG_CRIT, thr->log,
+ nxt_openssl_log_error(NXT_LOG_ALERT, thr->log,
"SSL_CTX_use_PrivateKey_file(\"%s\") failed",
key);
goto fail;
@@ -192,7 +192,7 @@ nxt_openssl_server_init(nxt_ssltls_conf_t *conf)
ciphers = (conf->ciphers != NULL) ? conf->ciphers : "HIGH:!aNULL:!MD5";
if (SSL_CTX_set_cipher_list(ctx, ciphers) == 0) {
- nxt_openssl_log_error(NXT_LOG_CRIT, thr->log,
+ nxt_openssl_log_error(NXT_LOG_ALERT, thr->log,
"SSL_CTX_set_cipher_list(\"%s\") failed",
ciphers);
goto fail;
@@ -211,7 +211,7 @@ nxt_openssl_server_init(nxt_ssltls_conf_t *conf)
ca_certificate = conf->ca_certificate;
if (SSL_CTX_load_verify_locations(ctx, ca_certificate, NULL) == 0) {
- nxt_openssl_log_error(NXT_LOG_CRIT, thr->log,
+ nxt_openssl_log_error(NXT_LOG_ALERT, thr->log,
"SSL_CTX_load_verify_locations(\"%s\") failed",
ca_certificate);
goto fail;
@@ -220,7 +220,7 @@ nxt_openssl_server_init(nxt_ssltls_conf_t *conf)
list = SSL_load_client_CA_file(ca_certificate);
if (list == NULL) {
- nxt_openssl_log_error(NXT_LOG_CRIT, thr->log,
+ nxt_openssl_log_error(NXT_LOG_ALERT, thr->log,
"SSL_load_client_CA_file(\"%s\") failed",
ca_certificate);
goto fail;
@@ -273,7 +273,8 @@ nxt_openssl_conn_init(nxt_task_t *task, nxt_ssltls_conf_t *conf, nxt_conn_t *c)
s = SSL_new(ctx);
if (s == NULL) {
- nxt_openssl_log_error(NXT_LOG_CRIT, c->socket.log, "SSL_new() failed");
+ nxt_openssl_log_error(NXT_LOG_ALERT, c->socket.log,
+ "SSL_new() failed");
goto fail;
}
@@ -284,7 +285,7 @@ nxt_openssl_conn_init(nxt_task_t *task, nxt_ssltls_conf_t *conf, nxt_conn_t *c)
ret = SSL_set_fd(s, c->socket.fd);
if (ret == 0) {
- nxt_openssl_log_error(NXT_LOG_CRIT, c->socket.log,
+ nxt_openssl_log_error(NXT_LOG_ALERT, c->socket.log,
"SSL_set_fd(%d) failed", c->socket.fd);
goto fail;
}
@@ -292,7 +293,7 @@ nxt_openssl_conn_init(nxt_task_t *task, nxt_ssltls_conf_t *conf, nxt_conn_t *c)
SSL_set_accept_state(s);
if (SSL_set_ex_data(s, nxt_openssl_connection_index, c) == 0) {
- nxt_openssl_log_error(NXT_LOG_CRIT, c->socket.log,
+ nxt_openssl_log_error(NXT_LOG_ALERT, c->socket.log,
"SSL_set_ex_data() failed");
goto fail;
}
@@ -760,7 +761,7 @@ nxt_openssl_log_error_level(nxt_conn_t *c, nxt_err_t err)
return NXT_LOG_ERR;
default:
- return NXT_LOG_CRIT;
+ return NXT_LOG_ALERT;
}
return NXT_LOG_INFO;
diff --git a/src/nxt_php_sapi.c b/src/nxt_php_sapi.c
index a12f6481..c4e5fe1c 100644
--- a/src/nxt_php_sapi.c
+++ b/src/nxt_php_sapi.c
@@ -191,7 +191,7 @@ nxt_php_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
c = &conf->u.php;
if (c->root == NULL) {
- nxt_log_emerg(task->log, "php root is empty");
+ nxt_alert(task, "php root is empty");
return NXT_ERROR;
}
@@ -202,8 +202,7 @@ nxt_php_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
root->start = nxt_realpath(c->root);
if (nxt_slow_path(root->start == NULL)) {
- nxt_log_emerg(task->log, "root realpath(%s) failed %E",
- c->root, nxt_errno);
+ nxt_alert(task, "root realpath(%s) failed %E", c->root, nxt_errno);
return NXT_ERROR;
}
@@ -228,15 +227,14 @@ nxt_php_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
rpath.start = nxt_realpath(path->start);
if (nxt_slow_path(rpath.start == NULL)) {
- nxt_log_emerg(task->log, "script realpath(%V) failed %E",
- path, nxt_errno);
+ nxt_alert(task, "script realpath(%V) failed %E", path, nxt_errno);
return NXT_ERROR;
}
rpath.length = nxt_strlen(rpath.start);
if (!nxt_str_start(&rpath, root->start, root->length)) {
- nxt_log_emerg(task->log, "script is not under php root");
+ nxt_alert(task, "script is not under php root");
return NXT_ERROR;
}
diff --git a/src/nxt_polarssl.c b/src/nxt_polarssl.c
index fcee2da0..4a814473 100644
--- a/src/nxt_polarssl.c
+++ b/src/nxt_polarssl.c
@@ -49,7 +49,7 @@ nxt_polarssl_server_init(nxt_ssltls_conf_t *conf)
n = ssl_init(&ctx->ssl);
if (n != 0) {
- nxt_polarssl_log_error(NXT_LOG_CRIT, thr->log, n, "ssl_init() failed");
+ nxt_polarssl_log_error(NXT_LOG_ALERT, thr->log, n, "ssl_init() failed");
return NXT_ERROR;
}
@@ -60,7 +60,7 @@ nxt_polarssl_server_init(nxt_ssltls_conf_t *conf)
n = x509parse_crtfile(&ctx->certificate, conf->certificate);
if (n != 0) {
- nxt_polarssl_log_error(NXT_LOG_CRIT, thr->log, n,
+ nxt_polarssl_log_error(NXT_LOG_ALERT, thr->log, n,
"x509parse_crt(\"%V\") failed",
&conf->certificate);
goto fail;
@@ -70,7 +70,7 @@ nxt_polarssl_server_init(nxt_ssltls_conf_t *conf)
n = x509parse_keyfile(&ctx->key, conf->certificate_key, NULL);
if (n != 0) {
- nxt_polarssl_log_error(NXT_LOG_CRIT, thr->log, n,
+ nxt_polarssl_log_error(NXT_LOG_ALERT, thr->log, n,
"x509parse_key(\"%V\") failed",
&conf->certificate_key);
goto fail;
diff --git a/src/nxt_poll_engine.c b/src/nxt_poll_engine.c
index cb41d182..9b70f8d6 100644
--- a/src/nxt_poll_engine.c
+++ b/src/nxt_poll_engine.c
@@ -546,9 +546,9 @@ nxt_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
phe = nxt_poll_fd_hash_get(engine, fd);
if (nxt_slow_path(phe == NULL)) {
- nxt_log(&engine->task, NXT_LOG_CRIT,
- "poll() returned invalid fd:%d ev:%04Xd rev:%04uXi",
- fd, pfd->events, events);
+ nxt_alert(&engine->task,
+ "poll() returned invalid fd:%d ev:%04Xd rev:%04uXi",
+ fd, pfd->events, events);
/* Mark the poll entry to ignore it by the kernel. */
pfd->fd = -1;
@@ -561,9 +561,8 @@ nxt_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
fd, events, ev->read, ev->write);
if (nxt_slow_path((events & POLLNVAL) != 0)) {
- nxt_log(ev->task, NXT_LOG_CRIT,
- "poll() error fd:%d ev:%04Xd rev:%04uXi",
- fd, pfd->events, events);
+ nxt_alert(ev->task, "poll() error fd:%d ev:%04Xd rev:%04uXi",
+ fd, pfd->events, events);
/* Mark the poll entry to ignore it by the kernel. */
pfd->fd = -1;
@@ -649,7 +648,7 @@ nxt_poll_fd_hash_get(nxt_event_engine_t *engine, nxt_fd_t fd)
return phe;
}
- nxt_log(&engine->task, NXT_LOG_CRIT, "fd %d not found in hash", fd);
+ nxt_alert(&engine->task, "fd %d not found in hash", fd);
return NULL;
}
@@ -671,9 +670,8 @@ nxt_poll_fd_hash_test(nxt_lvlhsh_query_t *lhq, void *data)
return NXT_OK;
}
- nxt_log(&engine->task, NXT_LOG_CRIT,
- "fd %d in hash mismatches fd %d in poll set",
- phe->fd, engine->u.poll.set[phe->index].fd);
+ nxt_alert(&engine->task, "fd %d in hash mismatches fd %d in poll set",
+ phe->fd, engine->u.poll.set[phe->index].fd);
return NXT_DECLINED;
}
@@ -700,8 +698,7 @@ nxt_poll_fd_hash_destroy(nxt_event_engine_t *engine, nxt_lvlhsh_t *lh)
lhq.key_hash = nxt_murmur_hash2(&phe->fd, sizeof(nxt_fd_t));
if (nxt_lvlhsh_delete(lh, &lhq) != NXT_OK) {
- nxt_log(&engine->task, NXT_LOG_CRIT,
- "event fd %d not found in hash", phe->fd);
+ nxt_alert(&engine->task, "event fd %d not found in hash", phe->fd);
}
nxt_free(phe);
diff --git a/src/nxt_pollset_engine.c b/src/nxt_pollset_engine.c
index 402f954c..e2c1a2d0 100644
--- a/src/nxt_pollset_engine.c
+++ b/src/nxt_pollset_engine.c
@@ -122,8 +122,7 @@ nxt_pollset_create(nxt_event_engine_t *engine, nxt_uint_t mchanges,
engine->u.pollset.ps = pollset_create(-1);
if (engine->u.pollset.ps == -1) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "pollset_create() failed %E",
- nxt_errno);
+ nxt_alert(&engine->task, "pollset_create() failed %E", nxt_errno);
goto fail;
}
@@ -149,8 +148,8 @@ nxt_pollset_free(nxt_event_engine_t *engine)
nxt_debug(&engine->task, "pollset %d free", ps);
if (ps != -1 && pollset_destroy(ps) != 0) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "pollset_destroy(%d) failed %E",
- ps, nxt_errno);
+ nxt_alert(&engine->task, "pollset_destroy(%d) failed %E",
+ ps, nxt_errno);
}
nxt_free(engine->u.pollset.events);
@@ -501,8 +500,8 @@ nxt_pollset_remove(nxt_event_engine_t *engine, nxt_fd_t fd)
}
if (n == -1) {
- nxt_log(&engine->task, NXT_LOG_CRIT, "pollset_query(%d, %d) failed %E",
- engine->u.pollset.ps, fd, nxt_errno);
+ nxt_alert(&engine->task, "pollset_query(%d, %d) failed %E",
+ engine->u.pollset.ps, fd, nxt_errno);
/* Fall through. */
}
@@ -536,8 +535,7 @@ nxt_pollset_write(nxt_event_engine_t *engine, struct poll_ctl *ctl, int n)
return NXT_OK;
}
- nxt_log(&engine->task, NXT_LOG_CRIT, "pollset_ctl(%d) failed: %d %E",
- ps, n, nxt_errno);
+ nxt_alert(&engine->task, "pollset_ctl(%d) failed: %d %E", ps, n, nxt_errno);
return NXT_ERROR;
}
@@ -575,7 +573,7 @@ nxt_pollset_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
engine->u.pollset.ps, nevents);
if (nevents == -1) {
- level = (err == NXT_EINTR) ? NXT_LOG_INFO : NXT_LOG_CRIT;
+ level = (err == NXT_EINTR) ? NXT_LOG_INFO : NXT_LOG_ALERT;
nxt_log(&engine->task, level, "pollset_poll(%d) failed %E",
engine->u.pollset.ps, err);
@@ -593,10 +591,10 @@ nxt_pollset_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
fd);
if (nxt_slow_path(ev == NULL)) {
- nxt_log(&engine->task, NXT_LOG_CRIT,
- "pollset_poll(%d) returned invalid "
- "fd:%d ev:%04Xd rev:%04uXi",
- engine->u.pollset.ps, fd, pfd->events, events);
+ nxt_alert(&engine->task,
+ "pollset_poll(%d) returned invalid "
+ "fd:%d ev:%04Xd rev:%04uXi",
+ engine->u.pollset.ps, fd, pfd->events, events);
nxt_pollset_remove(engine, fd);
continue;
@@ -605,9 +603,9 @@ nxt_pollset_poll(nxt_event_engine_t *engine, nxt_msec_t timeout)
nxt_debug(ev->task, "pollset: fd:%d ev:%04uXi", fd, events);
if (nxt_slow_path(events & (POLLERR | POLLHUP | POLLNVAL)) != 0) {
- nxt_log(ev->task, NXT_LOG_CRIT,
- "pollset_poll(%d) error fd:%d ev:%04Xd rev:%04uXi",
- engine->u.pollset.ps, fd, pfd->events, events);
+ nxt_alert(ev->task,
+ "pollset_poll(%d) error fd:%d ev:%04Xd rev:%04uXi",
+ engine->u.pollset.ps, fd, pfd->events, events);
nxt_work_queue_add(&engine->fast_work_queue, ev->error_handler,
ev->task, ev, ev->data);
diff --git a/src/nxt_port.c b/src/nxt_port.c
index 12de8afb..64dd4dd5 100644
--- a/src/nxt_port.c
+++ b/src/nxt_port.c
@@ -167,8 +167,8 @@ nxt_port_handler(nxt_task_t *task, nxt_port_recv_msg_t *msg)
return;
}
- nxt_log(task, NXT_LOG_CRIT, "port %d: unknown message type:%uD",
- msg->port->socket.fd, msg->port_msg.type);
+ nxt_alert(task, "port %d: unknown message type:%uD",
+ msg->port->socket.fd, msg->port_msg.type);
}
diff --git a/src/nxt_port_memory.c b/src/nxt_port_memory.c
index fbfefc32..f660b1b4 100644
--- a/src/nxt_port_memory.c
+++ b/src/nxt_port_memory.c
@@ -124,13 +124,7 @@ nxt_port_mmap_buf_completion(nxt_task_t *task, void *obj, void *data)
mp = b->data;
-#if (NXT_DEBUG)
- if (nxt_slow_path(data != b->parent)) {
- nxt_log_alert(task->log, "completion data (%p) != b->parent (%p)",
- data, b->parent);
- nxt_abort();
- }
-#endif
+ nxt_assert(data == b->parent);
mmap_handler = data;
hdr = mmap_handler->hdr;
@@ -296,8 +290,7 @@ nxt_port_new_port_mmap(nxt_task_t *task, nxt_process_t *process,
fd = syscall(SYS_memfd_create, name, MFD_CLOEXEC);
if (nxt_slow_path(fd == -1)) {
- nxt_log(task, NXT_LOG_CRIT, "memfd_create(%s) failed %E",
- name, nxt_errno);
+ nxt_alert(task, "memfd_create(%s) failed %E", name, nxt_errno);
goto remove_fail;
}
@@ -314,7 +307,7 @@ nxt_port_new_port_mmap(nxt_task_t *task, nxt_process_t *process,
nxt_debug(task, "shm_open(%s): %FD", name, fd);
if (nxt_slow_path(fd == -1)) {
- nxt_log(task, NXT_LOG_CRIT, "shm_open(%s) failed %E", name, nxt_errno);
+ nxt_alert(task, "shm_open(%s) failed %E", name, nxt_errno);
goto remove_fail;
}
diff --git a/src/nxt_port_socket.c b/src/nxt_port_socket.c
index 65096177..05a4845f 100644
--- a/src/nxt_port_socket.c
+++ b/src/nxt_port_socket.c
@@ -141,13 +141,7 @@ nxt_port_release_send_msg(nxt_task_t *task, void *obj, void *data)
msg = obj;
engine = data;
-#if (NXT_DEBUG)
- if (nxt_slow_path(data != msg->work.data)) {
- nxt_log_alert(task->log, "release msg data (%p) != msg->engine (%p)",
- data, msg->work.data);
- nxt_abort();
- }
-#endif
+ nxt_assert(data == msg->work.data);
if (engine != task->thread->engine) {
@@ -374,9 +368,8 @@ nxt_port_write_handler(nxt_task_t *task, void *obj, void *data)
if (n > 0) {
if (nxt_slow_path((size_t) n != sb.size + iov[0].iov_len)) {
- nxt_log(task, NXT_LOG_CRIT,
- "port %d: short write: %z instead of %uz",
- port->socket.fd, n, sb.size + iov[0].iov_len);
+ nxt_alert(task, "port %d: short write: %z instead of %uz",
+ port->socket.fd, n, sb.size + iov[0].iov_len);
goto fail;
}
@@ -691,8 +684,8 @@ nxt_port_read_msg_process(nxt_task_t *task, nxt_port_t *port,
nxt_port_recv_msg_t *fmsg;
if (nxt_slow_path(msg->size < sizeof(nxt_port_msg_t))) {
- nxt_log(task, NXT_LOG_CRIT,
- "port %d: too small message:%uz", port->socket.fd, msg->size);
+ nxt_alert(task, "port %d: too small message:%uz",
+ port->socket.fd, msg->size);
if (msg->fd != -1) {
nxt_fd_close(msg->fd);
diff --git a/src/nxt_process.c b/src/nxt_process.c
index 04c5f745..a717eb9e 100644
--- a/src/nxt_process.c
+++ b/src/nxt_process.c
@@ -51,8 +51,8 @@ nxt_process_create(nxt_task_t *task, nxt_process_t *process)
switch (pid) {
case -1:
- nxt_log(task, NXT_LOG_CRIT, "fork() failed while creating \"%s\" %E",
- process->init->name, nxt_errno);
+ nxt_alert(task, "fork() failed while creating \"%s\" %E",
+ process->init->name, nxt_errno);
break;
case 0:
@@ -236,8 +236,7 @@ nxt_process_execute(nxt_task_t *task, char *name, char **argv, char **envp)
nxt_debug(task, "posix_spawn(\"%s\")", name);
if (posix_spawn(&pid, name, NULL, NULL, argv, envp) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "posix_spawn(\"%s\") failed %E",
- name, nxt_errno);
+ nxt_alert(task, "posix_spawn(\"%s\") failed %E", name, nxt_errno);
return -1;
}
@@ -263,8 +262,8 @@ nxt_process_execute(nxt_task_t *task, char *name, char **argv, char **envp)
switch (pid) {
case -1:
- nxt_log(task, NXT_LOG_CRIT, "vfork() failed while executing \"%s\" %E",
- name, nxt_errno);
+ nxt_alert(task, "vfork() failed while executing \"%s\" %E",
+ name, nxt_errno);
break;
case 0:
@@ -273,8 +272,7 @@ nxt_process_execute(nxt_task_t *task, char *name, char **argv, char **envp)
(void) execve(name, argv, envp);
- nxt_log(task, NXT_LOG_CRIT, "execve(\"%s\") failed %E",
- name, nxt_errno);
+ nxt_alert(task, "execve(\"%s\") failed %E", name, nxt_errno);
exit(1);
nxt_unreachable();
@@ -336,7 +334,7 @@ nxt_process_daemon(nxt_task_t *task)
/* Detach from controlling terminal. */
if (setsid() == -1) {
- nxt_log(task, NXT_LOG_CRIT, "setsid() failed %E", nxt_errno);
+ nxt_alert(task, "setsid() failed %E", nxt_errno);
return NXT_ERROR;
}
@@ -372,7 +370,7 @@ nxt_process_daemon(nxt_task_t *task)
fail:
- nxt_log(task, NXT_LOG_CRIT, msg, nxt_errno);
+ nxt_alert(task, msg, nxt_errno);
if (fd != -1) {
nxt_fd_close(fd);
@@ -407,12 +405,10 @@ nxt_user_cred_get(nxt_task_t *task, nxt_user_cred_t *uc, const char *group)
if (nxt_slow_path(pwd == NULL)) {
if (nxt_errno == 0) {
- nxt_log(task, NXT_LOG_CRIT,
- "getpwnam(\"%s\") failed, user \"%s\" not found",
- uc->user, uc->user);
+ nxt_alert(task, "getpwnam(\"%s\") failed, user \"%s\" not found",
+ uc->user, uc->user);
} else {
- nxt_log(task, NXT_LOG_CRIT, "getpwnam(\"%s\") failed %E",
- uc->user, nxt_errno);
+ nxt_alert(task, "getpwnam(\"%s\") failed %E", uc->user, nxt_errno);
}
return NXT_ERROR;
@@ -429,12 +425,11 @@ nxt_user_cred_get(nxt_task_t *task, nxt_user_cred_t *uc, const char *group)
if (nxt_slow_path(grp == NULL)) {
if (nxt_errno == 0) {
- nxt_log(task, NXT_LOG_CRIT,
- "getgrnam(\"%s\") failed, group \"%s\" not found",
- group, group);
+ nxt_alert(task,
+ "getgrnam(\"%s\") failed, group \"%s\" not found",
+ group, group);
} else {
- nxt_log(task, NXT_LOG_CRIT, "getgrnam(\"%s\") failed %E",
- group, nxt_errno);
+ nxt_alert(task, "getgrnam(\"%s\") failed %E", group, nxt_errno);
}
return NXT_ERROR;
@@ -487,7 +482,7 @@ nxt_user_groups_get(nxt_task_t *task, nxt_user_cred_t *uc)
nsaved = getgroups(0, NULL);
if (nsaved == -1) {
- nxt_log(task, NXT_LOG_CRIT, "getgroups(0, NULL) failed %E", nxt_errno);
+ nxt_alert(task, "getgroups(0, NULL) failed %E", nxt_errno);
return NXT_ERROR;
}
@@ -509,23 +504,21 @@ nxt_user_groups_get(nxt_task_t *task, nxt_user_cred_t *uc)
nsaved = getgroups(nsaved, saved);
if (nsaved == -1) {
- nxt_log(task, NXT_LOG_CRIT, "getgroups(%d) failed %E",
- nsaved, nxt_errno);
+ nxt_alert(task, "getgroups(%d) failed %E", nsaved, nxt_errno);
goto fail;
}
nxt_debug(task, "getgroups(): %d", nsaved);
if (initgroups(uc->user, uc->base_gid) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "initgroups(%s, %d) failed",
- uc->user, uc->base_gid);
+ nxt_alert(task, "initgroups(%s, %d) failed", uc->user, uc->base_gid);
goto restore;
}
ngroups = getgroups(0, NULL);
if (ngroups == -1) {
- nxt_log(task, NXT_LOG_CRIT, "getgroups(0, NULL) failed %E", nxt_errno);
+ nxt_alert(task, "getgroups(0, NULL) failed %E", nxt_errno);
goto restore;
}
@@ -540,8 +533,7 @@ nxt_user_groups_get(nxt_task_t *task, nxt_user_cred_t *uc)
ngroups = getgroups(ngroups, uc->gids);
if (ngroups == -1) {
- nxt_log(task, NXT_LOG_CRIT, "getgroups(%d) failed %E",
- ngroups, nxt_errno);
+ nxt_alert(task, "getgroups(%d) failed %E", ngroups, nxt_errno);
goto restore;
}
@@ -571,8 +563,7 @@ nxt_user_groups_get(nxt_task_t *task, nxt_user_cred_t *uc)
restore:
if (setgroups(nsaved, saved) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "setgroups(%d) failed %E",
- nsaved, nxt_errno);
+ nxt_alert(task, "setgroups(%d) failed %E", nsaved, nxt_errno);
ret = NXT_ERROR;
}
@@ -591,29 +582,27 @@ nxt_user_cred_set(nxt_task_t *task, nxt_user_cred_t *uc)
uc->user, (uint64_t) uc->uid, (uint64_t) uc->base_gid);
if (setgid(uc->base_gid) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "setgid(%d) failed %E",
- uc->base_gid, nxt_errno);
+ nxt_alert(task, "setgid(%d) failed %E", uc->base_gid, nxt_errno);
return NXT_ERROR;
}
if (uc->gids != NULL) {
if (setgroups(uc->ngroups, uc->gids) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "setgroups(%i) failed %E",
- uc->ngroups, nxt_errno);
+ nxt_alert(task, "setgroups(%i) failed %E", uc->ngroups, nxt_errno);
return NXT_ERROR;
}
} else {
/* MacOSX fallback. */
if (initgroups(uc->user, uc->base_gid) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "initgroups(%s, %d) failed",
- uc->user, uc->base_gid);
+ nxt_alert(task, "initgroups(%s, %d) failed",
+ uc->user, uc->base_gid);
return NXT_ERROR;
}
}
if (setuid(uc->uid) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "setuid(%d) failed %E", uc->uid, nxt_errno);
+ nxt_alert(task, "setuid(%d) failed %E", uc->uid, nxt_errno);
return NXT_ERROR;
}
diff --git a/src/nxt_python_wsgi.c b/src/nxt_python_wsgi.c
index 3f2a4a14..15947fa0 100644
--- a/src/nxt_python_wsgi.c
+++ b/src/nxt_python_wsgi.c
@@ -197,7 +197,7 @@ nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
c = &conf->u.python;
if (c->module.length == 0) {
- nxt_log_emerg(task->log, "python module is empty");
+ nxt_alert(task, "python module is empty");
return NXT_ERROR;
}
@@ -208,7 +208,7 @@ nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
nxt_py_home = nxt_malloc(sizeof(*nxt_py_home) * (len + 1));
if (nxt_slow_path(nxt_py_home == NULL)) {
- nxt_log_emerg(task->log, "Failed to allocate buffer for home path");
+ nxt_alert(task, "Failed to allocate buffer for home path");
return NXT_ERROR;
}
@@ -231,24 +231,21 @@ nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
c->path.length);
if (nxt_slow_path(obj == NULL)) {
- nxt_log_alert(task->log,
- "Python failed create string object \"%V\"",
- &c->path);
+ nxt_alert(task, "Python failed create string object \"%V\"",
+ &c->path);
goto fail;
}
pypath = PySys_GetObject((char *) "path");
if (nxt_slow_path(pypath == NULL)) {
- nxt_log_alert(task->log,
- "Python failed to get \"sys.path\" list");
+ nxt_alert(task, "Python failed to get \"sys.path\" list");
goto fail;
}
if (nxt_slow_path(PyList_Insert(pypath, 0, obj) != 0)) {
- nxt_log_alert(task->log,
- "Python failed to insert \"%V\" into \"sys.path\"",
- &c->path);
+ nxt_alert(task, "Python failed to insert \"%V\" into \"sys.path\"",
+ &c->path);
goto fail;
}
@@ -259,7 +256,7 @@ nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
obj = PyCFunction_New(nxt_py_start_resp_method, NULL);
if (nxt_slow_path(obj == NULL)) {
- nxt_log_alert(task->log,
+ nxt_alert(task,
"Python failed to initialize the \"start_response\" function");
goto fail;
}
@@ -276,13 +273,12 @@ nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
obj = Py_BuildValue("[s]", "unit");
if (obj == NULL) {
- nxt_log_alert(task->log,
- "Python failed to create the \"sys.argv\" list");
+ nxt_alert(task, "Python failed to create the \"sys.argv\" list");
goto fail;
}
if (PySys_SetObject((char *) "argv", obj) != 0) {
- nxt_log_alert(task->log, "Python failed to set the \"sys.argv\" list");
+ nxt_alert(task, "Python failed to set the \"sys.argv\" list");
goto fail;
}
@@ -295,8 +291,7 @@ nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
module = PyImport_ImportModule(nxt_py_module);
if (nxt_slow_path(module == NULL)) {
- nxt_log_emerg(task->log, "Python failed to import module \"%s\"",
- nxt_py_module);
+ nxt_alert(task, "Python failed to import module \"%s\"", nxt_py_module);
PyErr_PrintEx(1);
return NXT_ERROR;
}
@@ -304,14 +299,14 @@ nxt_python_init(nxt_task_t *task, nxt_common_app_conf_t *conf)
obj = PyDict_GetItemString(PyModule_GetDict(module), "application");
if (nxt_slow_path(obj == NULL)) {
- nxt_log_emerg(task->log, "Python failed to get \"application\" "
- "from module \"%s\"", nxt_py_module);
+ nxt_alert(task, "Python failed to get \"application\" "
+ "from module \"%s\"", nxt_py_module);
goto fail;
}
if (nxt_slow_path(PyCallable_Check(obj) == 0)) {
- nxt_log_emerg(task->log, "\"application\" in module \"%s\" "
- "is not a callable object", nxt_py_module);
+ nxt_alert(task, "\"application\" in module \"%s\" "
+ "is not a callable object", nxt_py_module);
PyErr_PrintEx(1);
goto fail;
}
@@ -479,23 +474,22 @@ nxt_python_create_environ(nxt_task_t *task)
environ = PyDict_New();
if (nxt_slow_path(environ == NULL)) {
- nxt_log_alert(task->log,
- "Python failed to create the \"environ\" dictionary");
+ nxt_alert(task, "Python failed to create the \"environ\" dictionary");
return NULL;
}
obj = Py_BuildValue("(ii)", 1, 0);
if (nxt_slow_path(obj == NULL)) {
- nxt_log_alert(task->log,
+ nxt_alert(task,
"Python failed to build the \"wsgi.version\" environ value");
goto fail;
}
if (nxt_slow_path(PyDict_SetItemString(environ, "wsgi.version", obj) != 0))
{
- nxt_log_alert(task->log,
- "Python failed to set the \"wsgi.version\" environ value");
+ nxt_alert(task,
+ "Python failed to set the \"wsgi.version\" environ value");
goto fail;
}
@@ -507,7 +501,7 @@ nxt_python_create_environ(nxt_task_t *task)
Py_False)
!= 0))
{
- nxt_log_alert(task->log,
+ nxt_alert(task,
"Python failed to set the \"wsgi.multithread\" environ value");
goto fail;
}
@@ -516,7 +510,7 @@ nxt_python_create_environ(nxt_task_t *task)
Py_True)
!= 0))
{
- nxt_log_alert(task->log,
+ nxt_alert(task,
"Python failed to set the \"wsgi.multiprocess\" environ value");
goto fail;
}
@@ -525,8 +519,8 @@ nxt_python_create_environ(nxt_task_t *task)
Py_False)
!= 0))
{
- nxt_log_alert(task->log,
- "Python failed to set the \"wsgi.run_once\" environ value");
+ nxt_alert(task,
+ "Python failed to set the \"wsgi.run_once\" environ value");
goto fail;
}
@@ -534,7 +528,7 @@ nxt_python_create_environ(nxt_task_t *task)
obj = PyString_FromString("http");
if (nxt_slow_path(obj == NULL)) {
- nxt_log_alert(task->log,
+ nxt_alert(task,
"Python failed to create the \"wsgi.url_scheme\" environ value");
goto fail;
}
@@ -542,8 +536,8 @@ nxt_python_create_environ(nxt_task_t *task)
if (nxt_slow_path(PyDict_SetItemString(environ, "wsgi.url_scheme", obj)
!= 0))
{
- nxt_log_alert(task->log,
- "Python failed to set the \"wsgi.url_scheme\" environ value");
+ nxt_alert(task,
+ "Python failed to set the \"wsgi.url_scheme\" environ value");
goto fail;
}
@@ -552,22 +546,21 @@ nxt_python_create_environ(nxt_task_t *task)
if (nxt_slow_path(PyType_Ready(&nxt_py_input_type) != 0)) {
- nxt_log_alert(task->log,
- "Python failed to initialize the \"wsgi.input\" type object");
+ nxt_alert(task,
+ "Python failed to initialize the \"wsgi.input\" type object");
goto fail;
}
obj = (PyObject *) PyObject_New(nxt_py_input_t, &nxt_py_input_type);
if (nxt_slow_path(obj == NULL)) {
- nxt_log_alert(task->log,
- "Python failed to create the \"wsgi.input\" object");
+ nxt_alert(task, "Python failed to create the \"wsgi.input\" object");
goto fail;
}
if (nxt_slow_path(PyDict_SetItemString(environ, "wsgi.input", obj) != 0)) {
- nxt_log_alert(task->log,
- "Python failed to set the \"wsgi.input\" environ value");
+ nxt_alert(task,
+ "Python failed to set the \"wsgi.input\" environ value");
goto fail;
}
@@ -578,14 +571,14 @@ nxt_python_create_environ(nxt_task_t *task)
err = PySys_GetObject((char *) "stderr");
if (nxt_slow_path(err == NULL)) {
- nxt_log_alert(task->log, "Python failed to get \"sys.stderr\" object");
+ nxt_alert(task, "Python failed to get \"sys.stderr\" object");
goto fail;
}
if (nxt_slow_path(PyDict_SetItemString(environ, "wsgi.errors", err) != 0))
{
- nxt_log_alert(task->log,
- "Python failed to set the \"wsgi.errors\" environ value");
+ nxt_alert(task,
+ "Python failed to set the \"wsgi.errors\" environ value");
goto fail;
}
diff --git a/src/nxt_router.c b/src/nxt_router.c
index 5e1b8353..0afef978 100644
--- a/src/nxt_router.c
+++ b/src/nxt_router.c
@@ -990,7 +990,7 @@ nxt_router_conf_error(nxt_task_t *task, nxt_router_temp_conf_t *tmcf)
nxt_queue_link_t *qlk;
nxt_socket_conf_t *skcf;
- nxt_log(task, NXT_LOG_CRIT, "failed to apply new conf");
+ nxt_alert(task, "failed to apply new conf");
for (qlk = nxt_queue_first(&tmcf->creating);
qlk != nxt_queue_tail(&tmcf->creating);
@@ -1206,7 +1206,7 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
conf = nxt_conf_json_parse(tmcf->mem_pool, start, end, NULL);
if (conf == NULL) {
- nxt_log(task, NXT_LOG_CRIT, "configuration parsing error");
+ nxt_alert(task, "configuration parsing error");
return NXT_ERROR;
}
@@ -1215,7 +1215,7 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
ret = nxt_conf_map_object(mp, conf, nxt_router_conf,
nxt_nitems(nxt_router_conf), tmcf->conf);
if (ret != NXT_OK) {
- nxt_log(task, NXT_LOG_CRIT, "root map error");
+ nxt_alert(task, "root map error");
return NXT_ERROR;
}
@@ -1225,7 +1225,7 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
applications = nxt_conf_get_path(conf, &applications_path);
if (applications == NULL) {
- nxt_log(task, NXT_LOG_CRIT, "no \"applications\" block");
+ nxt_alert(task, "no \"applications\" block");
return NXT_ERROR;
}
@@ -1283,14 +1283,14 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
ret = nxt_conf_map_object(mp, application, nxt_router_app_conf,
nxt_nitems(nxt_router_app_conf), &apcf);
if (ret != NXT_OK) {
- nxt_log(task, NXT_LOG_CRIT, "application map error");
+ nxt_alert(task, "application map error");
goto app_fail;
}
if (apcf.limits_value != NULL) {
if (nxt_conf_type(apcf.limits_value) != NXT_CONF_OBJECT) {
- nxt_log(task, NXT_LOG_CRIT, "application limits is not object");
+ nxt_alert(task, "application limits is not object");
goto app_fail;
}
@@ -1299,7 +1299,7 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
nxt_nitems(nxt_router_app_limits_conf),
&apcf);
if (ret != NXT_OK) {
- nxt_log(task, NXT_LOG_CRIT, "application limits map error");
+ nxt_alert(task, "application limits map error");
goto app_fail;
}
}
@@ -1312,7 +1312,7 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
nxt_nitems(nxt_router_app_processes_conf),
&apcf);
if (ret != NXT_OK) {
- nxt_log(task, NXT_LOG_CRIT, "application processes map error");
+ nxt_alert(task, "application processes map error");
goto app_fail;
}
@@ -1330,8 +1330,7 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
lang = nxt_app_lang_module(task->thread->runtime, &apcf.type);
if (lang == NULL) {
- nxt_log(task, NXT_LOG_CRIT, "unknown application type: \"%V\"",
- &apcf.type);
+ nxt_alert(task, "unknown application type: \"%V\"", &apcf.type);
goto app_fail;
}
@@ -1386,14 +1385,14 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
http = nxt_conf_get_path(conf, &http_path);
#if 0
if (http == NULL) {
- nxt_log(task, NXT_LOG_CRIT, "no \"http\" block");
+ nxt_alert(task, "no \"http\" block");
return NXT_ERROR;
}
#endif
listeners = nxt_conf_get_path(conf, &listeners_path);
if (listeners == NULL) {
- nxt_log(task, NXT_LOG_CRIT, "no \"listeners\" block");
+ nxt_alert(task, "no \"listeners\" block");
return NXT_ERROR;
}
@@ -1413,7 +1412,7 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
ret = nxt_conf_map_object(mp, listener, nxt_router_listener_conf,
nxt_nitems(nxt_router_listener_conf), &lscf);
if (ret != NXT_OK) {
- nxt_log(task, NXT_LOG_CRIT, "listener map error");
+ nxt_alert(task, "listener map error");
goto fail;
}
@@ -1434,7 +1433,7 @@ nxt_router_conf_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
ret = nxt_conf_map_object(mp, http, nxt_router_http_conf,
nxt_nitems(nxt_router_http_conf), skcf);
if (ret != NXT_OK) {
- nxt_log(task, NXT_LOG_CRIT, "http map error");
+ nxt_alert(task, "http map error");
goto fail;
}
}
@@ -1514,7 +1513,7 @@ nxt_router_socket_conf(nxt_task_t *task, nxt_router_temp_conf_t *tmcf,
sa = nxt_sockaddr_parse(tmcf->mem_pool, name);
if (nxt_slow_path(sa == NULL)) {
- nxt_log(task, NXT_LOG_CRIT, "invalid listener \"%V\"", name);
+ nxt_alert(task, "invalid listener \"%V\"", name);
return NULL;
}
diff --git a/src/nxt_runtime.c b/src/nxt_runtime.c
index d60c0713..859cc7cb 100644
--- a/src/nxt_runtime.c
+++ b/src/nxt_runtime.c
@@ -157,7 +157,7 @@ nxt_runtime_inherited_listen_sockets(nxt_task_t *task, nxt_runtime_t *rt)
return nxt_runtime_systemd_listen_sockets(task, rt);
}
- nxt_log(task, NXT_LOG_CRIT, "using inherited listen sockets: %s", v);
+ nxt_alert(task, "using inherited listen sockets: %s", v);
inherited_sockets = nxt_array_create(rt->mem_pool,
1, sizeof(nxt_listen_socket_t));
@@ -173,9 +173,9 @@ nxt_runtime_inherited_listen_sockets(nxt_task_t *task, nxt_runtime_t *rt)
s = nxt_int_parse(v, p - v);
if (nxt_slow_path(s < 0)) {
- nxt_log(task, NXT_LOG_CRIT, "invalid socket number "
- "\"%s\" in NGINX environment variable, "
- "ignoring the rest of the variable", v);
+ nxt_alert(task, "invalid socket number \"%s\" "
+ "in NGINX environment variable, "
+ "ignoring the rest of the variable", v);
return NXT_ERROR;
}
@@ -890,8 +890,7 @@ nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt)
if (nxt_strcmp(p, "--upstream") == 0) {
if (*argv == NULL) {
- nxt_log(task, NXT_LOG_CRIT,
- "no argument for option \"--upstream\"");
+ nxt_alert(task, "no argument for option \"--upstream\"");
return NXT_ERROR;
}
@@ -1060,14 +1059,12 @@ nxt_runtime_sockaddr_unix_parse(nxt_task_t *task, nxt_mp_t *mp, nxt_str_t *addr)
p = addr->start + 5;
if (length == 0) {
- nxt_log(task, NXT_LOG_CRIT,
- "unix domain socket \"%V\" name is invalid", addr);
+ nxt_alert(task, "unix domain socket \"%V\" name is invalid", addr);
return NULL;
}
if (length > max_len) {
- nxt_log(task, NXT_LOG_CRIT,
- "unix domain socket \"%V\" name is too long", addr);
+ nxt_alert(task, "unix domain socket \"%V\" name is too long", addr);
return NULL;
}
@@ -1106,8 +1103,7 @@ nxt_runtime_sockaddr_unix_parse(nxt_task_t *task, nxt_mp_t *mp, nxt_str_t *addr)
#else /* !(NXT_HAVE_UNIX_DOMAIN) */
- nxt_log(task, NXT_LOG_CRIT, "unix domain socket \"%V\" is not supported",
- addr);
+ nxt_alert(task, "unix domain socket \"%V\" is not supported", addr);
return NULL;
@@ -1163,7 +1159,7 @@ nxt_runtime_sockaddr_inet6_parse(nxt_task_t *task, nxt_mp_t *mp,
}
}
- nxt_log(task, NXT_LOG_CRIT, "invalid port in \"%V\"", addr);
+ nxt_alert(task, "invalid port in \"%V\"", addr);
return NULL;
@@ -1178,13 +1174,13 @@ found:
invalid_address:
- nxt_log(task, NXT_LOG_CRIT, "invalid IPv6 address in \"%V\"", addr);
+ nxt_alert(task, "invalid IPv6 address in \"%V\"", addr);
return NULL;
#else
- nxt_log(task, NXT_LOG_CRIT, "IPv6 socket \"%V\" is not supported", addr);
+ nxt_alert(task, "IPv6 socket \"%V\" is not supported", addr);
return NULL;
@@ -1275,13 +1271,13 @@ nxt_runtime_sockaddr_inet_parse(nxt_task_t *task, nxt_mp_t *mp,
invalid_port:
- nxt_log(task, NXT_LOG_CRIT, "invalid port in \"%V\"", string);
+ nxt_alert(task, "invalid port in \"%V\"", string);
return NULL;
invalid_addr:
- nxt_log(task, NXT_LOG_CRIT, "invalid address in \"%V\"", string);
+ nxt_alert(task, "invalid address in \"%V\"", string);
return NULL;
}
@@ -1324,7 +1320,7 @@ nxt_runtime_hostname(nxt_task_t *task, nxt_runtime_t *rt)
char hostname[NXT_MAXHOSTNAMELEN + 1];
if (gethostname(hostname, NXT_MAXHOSTNAMELEN) != 0) {
- nxt_log(task, NXT_LOG_CRIT, "gethostname() failed %E", nxt_errno);
+ nxt_alert(task, "gethostname() failed %E", nxt_errno);
return NXT_ERROR;
}
@@ -1367,7 +1363,7 @@ nxt_runtime_log_files_init(nxt_runtime_t *rt)
file = nxt_list_zero_add(log_files);
file->fd = NXT_FILE_INVALID;
- file->log_level = NXT_LOG_CRIT;
+ file->log_level = NXT_LOG_ALERT;
return NXT_OK;
}
@@ -1408,7 +1404,7 @@ nxt_runtime_log_file_add(nxt_runtime_t *rt, nxt_str_t *name)
}
file->fd = NXT_FILE_INVALID;
- file->log_level = NXT_LOG_CRIT;
+ file->log_level = NXT_LOG_ALERT;
file->name = file_name.start;
return file;
diff --git a/src/nxt_service.c b/src/nxt_service.c
index e96e7c58..cc9f8d89 100644
--- a/src/nxt_service.c
+++ b/src/nxt_service.c
@@ -107,7 +107,7 @@ nxt_service_add(nxt_array_t *services, const nxt_service_t *service)
goto next;
}
- nxt_thread_log_emerg("service \"%s:%s\" is duplicate",
+ nxt_thread_log_alert("service \"%s:%s\" is duplicate",
service->type, service->name);
return NXT_ERROR;
@@ -158,7 +158,7 @@ nxt_service_get(nxt_array_t *services, const char *type, const char *name)
n--;
}
- nxt_thread_log_emerg("service \"%s%s%s\" not found",
+ nxt_thread_log_alert("service \"%s%s%s\" not found",
type, (name != NULL) ? ":" : "", name);
return NULL;
diff --git a/src/nxt_socket.c b/src/nxt_socket.c
index d7cdd600..eba53354 100644
--- a/src/nxt_socket.c
+++ b/src/nxt_socket.c
@@ -28,8 +28,8 @@ nxt_socket_create(nxt_task_t *task, nxt_uint_t domain, nxt_uint_t type,
s = socket(domain, type, protocol);
if (nxt_slow_path(s == -1)) {
- nxt_log(task, NXT_LOG_CRIT, "socket(%ui, 0x%uXi, %ui) failed %E",
- domain, type, protocol, nxt_socket_errno);
+ nxt_alert(task, "socket(%ui, 0x%uXi, %ui) failed %E",
+ domain, type, protocol, nxt_socket_errno);
return s;
}
@@ -57,8 +57,7 @@ nxt_socket_close(nxt_task_t *task, nxt_socket_t s)
nxt_debug(task, "socket close(%d)", s);
} else {
- nxt_log(task, NXT_LOG_CRIT, "socket close(%d) failed %E",
- s, nxt_socket_errno);
+ nxt_alert(task, "socket close(%d) failed %E", s, nxt_socket_errno);
}
}
@@ -99,9 +98,9 @@ nxt_socket_getsockopt(nxt_task_t *task, nxt_socket_t s, nxt_uint_t level,
return val;
}
- nxt_log(task, NXT_LOG_CRIT, "getsockopt(%d, %ui, %s) failed %E",
- s, level, nxt_socket_sockopt_name(level, sockopt),
- nxt_socket_errno);
+ nxt_alert(task, "getsockopt(%d, %ui, %s) failed %E",
+ s, level, nxt_socket_sockopt_name(level, sockopt),
+ nxt_socket_errno);
return -1;
}
@@ -121,9 +120,9 @@ nxt_socket_setsockopt(nxt_task_t *task, nxt_socket_t s, nxt_uint_t level,
return NXT_OK;
}
- nxt_log(task, NXT_LOG_CRIT, "setsockopt(%d, %ui, %s, %d) failed %E",
- s, level, nxt_socket_sockopt_name(level, sockopt),
- val, nxt_socket_errno);
+ nxt_alert(task, "setsockopt(%d, %ui, %s, %d) failed %E",
+ s, level, nxt_socket_sockopt_name(level, sockopt), val,
+ nxt_socket_errno);
return NXT_ERROR;
}
@@ -203,8 +202,8 @@ nxt_socket_bind(nxt_task_t *task, nxt_socket_t s, nxt_sockaddr_t *sa,
return NXT_DECLINED;
}
- nxt_log(task, NXT_LOG_CRIT, "bind(%d, %*s) failed %E",
- s, (size_t) sa->length, nxt_sockaddr_start(sa), err);
+ nxt_alert(task, "bind(%d, %*s) failed %E",
+ s, (size_t) sa->length, nxt_sockaddr_start(sa), err);
return NXT_ERROR;
}
@@ -255,7 +254,7 @@ nxt_socket_connect(nxt_task_t *task, nxt_socket_t s, nxt_sockaddr_t *sa)
break;
default:
- level = NXT_LOG_CRIT;
+ level = NXT_LOG_ALERT;
ret = NXT_ERROR;
}
@@ -294,7 +293,7 @@ nxt_socket_shutdown(nxt_task_t *task, nxt_socket_t s, nxt_uint_t how)
break;
default:
- level = NXT_LOG_CRIT;
+ level = NXT_LOG_ALERT;
}
nxt_log(task, level, "shutdown(%d, %ui) failed %E", s, how, err);
@@ -317,6 +316,6 @@ nxt_socket_error_level(nxt_err_t err)
return NXT_LOG_ERR;
default:
- return NXT_LOG_CRIT;
+ return NXT_LOG_ALERT;
}
}
diff --git a/src/nxt_socketpair.c b/src/nxt_socketpair.c
index efa0f486..a7396b31 100644
--- a/src/nxt_socketpair.c
+++ b/src/nxt_socketpair.c
@@ -30,7 +30,7 @@ nxt_int_t
nxt_socketpair_create(nxt_task_t *task, nxt_socket_t *pair)
{
if (nxt_slow_path(socketpair(AF_UNIX, NXT_UNIX_SOCKET, 0, pair) != 0)) {
- nxt_log(task, NXT_LOG_CRIT, "socketpair() failed %E", nxt_errno);
+ nxt_alert(task, "socketpair() failed %E", nxt_errno);
return NXT_ERROR;
}
@@ -103,8 +103,8 @@ nxt_socketpair_send(nxt_fd_event_t *ev, nxt_fd_t fd, nxt_iobuf_t *iob,
continue;
default:
- nxt_log(ev->task, NXT_LOG_CRIT, "sendmsg(%d, %FD, %ui) failed %E",
- ev->fd, fd, niob, err);
+ nxt_alert(ev->task, "sendmsg(%d, %FD, %ui) failed %E",
+ ev->fd, fd, niob, err);
return NXT_ERROR;
}
@@ -152,8 +152,8 @@ nxt_socketpair_recv(nxt_fd_event_t *ev, nxt_fd_t *fd, nxt_iobuf_t *iob,
continue;
default:
- nxt_log(ev->task, NXT_LOG_CRIT, "recvmsg(%d, %p, %ui) failed %E",
- ev->fd, fd, niob, err);
+ nxt_alert(ev->task, "recvmsg(%d, %p, %ui) failed %E",
+ ev->fd, fd, niob, err);
return NXT_ERROR;
}
diff --git a/src/nxt_thread.c b/src/nxt_thread.c
index 0619ad1b..a4ef416f 100644
--- a/src/nxt_thread.c
+++ b/src/nxt_thread.c
@@ -33,7 +33,7 @@ nxt_thread_init_data(nxt_thread_specific_data_t tsd)
err = pthread_key_create(&key, nxt_thread_key_dtor);
if (err != 0) {
- nxt_main_log_emerg("pthread_key_create() failed %E", err);
+ nxt_main_log_alert("pthread_key_create() failed %E", err);
goto fail;
}
diff --git a/src/nxt_thread_cond.c b/src/nxt_thread_cond.c
index 8db5a337..fcd108e4 100644
--- a/src/nxt_thread_cond.c
+++ b/src/nxt_thread_cond.c
@@ -18,7 +18,7 @@ nxt_thread_cond_create(nxt_thread_cond_t *cond)
return NXT_OK;
}
- nxt_thread_log_emerg("pthread_cond_init() failed %E", err);
+ nxt_thread_log_alert("pthread_cond_init() failed %E", err);
return NXT_ERROR;
}
diff --git a/src/nxt_thread_log.h b/src/nxt_thread_log.h
index 2950ae3e..214098ff 100644
--- a/src/nxt_thread_log.h
+++ b/src/nxt_thread_log.h
@@ -8,15 +8,6 @@
#define _NXT_THREAD_LOG_H_INCLUDED_
-#define nxt_thread_log_emerg(...) \
- do { \
- nxt_thread_t *_thr = nxt_thread(); \
- \
- nxt_log_emerg(_thr->log, __VA_ARGS__); \
- \
- } while (0)
-
-
#define nxt_thread_log_alert(...) \
do { \
nxt_thread_t *_thr = nxt_thread(); \
diff --git a/src/nxt_thread_mutex.c b/src/nxt_thread_mutex.c
index 10c08c2a..472a69f0 100644
--- a/src/nxt_thread_mutex.c
+++ b/src/nxt_thread_mutex.c
@@ -85,20 +85,20 @@ nxt_thread_mutex_create(nxt_thread_mutex_t *mtx)
err = pthread_mutexattr_init(&attr);
if (err != 0) {
- nxt_thread_log_emerg("pthread_mutexattr_init() failed %E", err);
+ nxt_thread_log_alert("pthread_mutexattr_init() failed %E", err);
return NXT_ERROR;
}
err = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK);
if (err != 0) {
- nxt_thread_log_emerg("pthread_mutexattr_settype"
+ nxt_thread_log_alert("pthread_mutexattr_settype"
"(PTHREAD_MUTEX_ERRORCHECK) failed %E", err);
return NXT_ERROR;
}
err = pthread_mutex_init(mtx, &attr);
if (err != 0) {
- nxt_thread_log_emerg("pthread_mutex_init() failed %E", err);
+ nxt_thread_log_alert("pthread_mutex_init() failed %E", err);
return NXT_ERROR;
}
diff --git a/src/perl/nxt_perl_psgi.c b/src/perl/nxt_perl_psgi.c
index c5c2774c..72ba0513 100644
--- a/src/perl/nxt_perl_psgi.c
+++ b/src/perl/nxt_perl_psgi.c
@@ -437,8 +437,7 @@ nxt_perl_psgi_interpreter_init(nxt_task_t *task, char *script)
my_perl = perl_alloc();
if (nxt_slow_path(my_perl == NULL)) {
- nxt_log_error(NXT_LOG_CRIT, task->log,
- "PSGI: Failed to allocate memory for Perl interpreter");
+ nxt_alert(task, "PSGI: Failed to allocate memory for Perl interpreter");
return NULL;
}
@@ -450,8 +449,7 @@ nxt_perl_psgi_interpreter_init(nxt_task_t *task, char *script)
status = perl_parse(my_perl, nxt_perl_psgi_xs_init, 3, embedding, NULL);
if (nxt_slow_path(status != 0)) {
- nxt_log_error(NXT_LOG_CRIT, task->log,
- "PSGI: Failed to parse Perl Script");
+ nxt_alert(task, "PSGI: Failed to parse Perl Script");
goto fail;
}
@@ -461,8 +459,7 @@ nxt_perl_psgi_interpreter_init(nxt_task_t *task, char *script)
status = perl_run(my_perl);
if (nxt_slow_path(status != 0)) {
- nxt_log_error(NXT_LOG_CRIT, task->log,
- "PSGI: Failed to run Perl");
+ nxt_alert(task, "PSGI: Failed to run Perl");
goto fail;
}
@@ -477,24 +474,22 @@ nxt_perl_psgi_interpreter_init(nxt_task_t *task, char *script)
status = nxt_perl_psgi_io_input_init(my_perl, &nxt_perl_psgi_arg_input);
if (nxt_slow_path(status != NXT_OK)) {
- nxt_log_error(NXT_LOG_CRIT, task->log,
- "PSGI: Failed to init io.psgi.input");
+ nxt_alert(task, "PSGI: Failed to init io.psgi.input");
goto fail;
}
status = nxt_perl_psgi_io_error_init(my_perl, &nxt_perl_psgi_arg_error);
if (nxt_slow_path(status != NXT_OK)) {
- nxt_log_error(NXT_LOG_CRIT, task->log,
- "PSGI: Failed to init io.psgi.errors");
+ nxt_alert(task, "PSGI: Failed to init io.psgi.errors");
goto fail;
}
nxt_perl_psgi_app = eval_pv((const char *) run_module, FALSE);
if (SvTRUE(ERRSV)) {
- nxt_log_emerg(task->log, "PSGI: Failed to parse script: %s\n%s",
- script, SvPV_nolen(ERRSV));
+ nxt_alert(task, "PSGI: Failed to parse script: %s\n%s",
+ script, SvPV_nolen(ERRSV));
goto fail;
}