[njs] Fixed error logging in js_include.

Dmitry Volyntsev xeioex at nginx.com
Mon May 28 14:06:38 UTC 2018


details:   http://hg.nginx.org/njs/rev/481402695c87
branches:  
changeset: 524:481402695c87
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Mon May 28 17:05:16 2018 +0300
description:
Fixed error logging in js_include.

Previously, ngx_log_error() was used instead of ngx_conf_log_error()
in js_include directive handler.   Replacing it with ngx_conf_log_error()
to report the additional information about the location of the directive
in the configuration file.

diffstat:

 nginx/ngx_http_js_module.c   |  18 +++++++++---------
 nginx/ngx_stream_js_module.c |  18 +++++++++---------
 2 files changed, 18 insertions(+), 18 deletions(-)

diffs (94 lines):

diff -r 822f975c933a -r 481402695c87 nginx/ngx_http_js_module.c
--- a/nginx/ngx_http_js_module.c	Thu May 24 20:32:09 2018 +0300
+++ b/nginx/ngx_http_js_module.c	Mon May 28 17:05:16 2018 +0300
@@ -2189,8 +2189,8 @@ ngx_http_js_include(ngx_conf_t *cf, ngx_
     }
 
     if (ngx_fd_info(fd, &fi) == NGX_FILE_ERROR) {
-        ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
-                      ngx_fd_info_n " \"%s\" failed", file.data);
+        ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
+                           ngx_fd_info_n " \"%s\" failed", file.data);
         (void) ngx_close_file(fd);
         return NGX_CONF_ERROR;
     }
@@ -2206,25 +2206,25 @@ ngx_http_js_include(ngx_conf_t *cf, ngx_
     n = ngx_read_fd(fd, start,  size);
 
     if (n == -1) {
-        ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
-                      ngx_read_fd_n " \"%s\" failed", file.data);
+        ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
+                           ngx_read_fd_n " \"%s\" failed", file.data);
 
         (void) ngx_close_file(fd);
         return NGX_CONF_ERROR;
     }
 
     if ((size_t) n != size) {
-        ngx_log_error(NGX_LOG_ALERT, cf->log, 0,
-                      ngx_read_fd_n " has read only %z of %O from \"%s\"",
-                      n, size, file.data);
+        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                           ngx_read_fd_n " has read only %z of %O from \"%s\"",
+                           n, size, file.data);
 
         (void) ngx_close_file(fd);
         return NGX_CONF_ERROR;
     }
 
     if (ngx_close_file(fd) == NGX_FILE_ERROR) {
-        ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
-                      ngx_close_file_n " %s failed", file.data);
+        ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
+                           ngx_close_file_n " %s failed", file.data);
     }
 
     end = start + size;
diff -r 822f975c933a -r 481402695c87 nginx/ngx_stream_js_module.c
--- a/nginx/ngx_stream_js_module.c	Thu May 24 20:32:09 2018 +0300
+++ b/nginx/ngx_stream_js_module.c	Mon May 28 17:05:16 2018 +0300
@@ -978,8 +978,8 @@ ngx_stream_js_include(ngx_conf_t *cf, ng
     }
 
     if (ngx_fd_info(fd, &fi) == NGX_FILE_ERROR) {
-        ngx_log_error(NGX_LOG_EMERG, cf->log, ngx_errno,
-                      ngx_fd_info_n " \"%s\" failed", file.data);
+        ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
+                           ngx_fd_info_n " \"%s\" failed", file.data);
         (void) ngx_close_file(fd);
         return NGX_CONF_ERROR;
     }
@@ -995,25 +995,25 @@ ngx_stream_js_include(ngx_conf_t *cf, ng
     n = ngx_read_fd(fd, start,  size);
 
     if (n == -1) {
-        ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
-                      ngx_read_fd_n " \"%s\" failed", file.data);
+        ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
+                           ngx_read_fd_n " \"%s\" failed", file.data);
 
         (void) ngx_close_file(fd);
         return NGX_CONF_ERROR;
     }
 
     if ((size_t) n != size) {
-        ngx_log_error(NGX_LOG_ALERT, cf->log, 0,
-                      ngx_read_fd_n " has read only %z of %uz from \"%s\"",
-                      n, size, file.data);
+        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                           ngx_read_fd_n " has read only %z of %uz from \"%s\"",
+                           n, size, file.data);
 
         (void) ngx_close_file(fd);
         return NGX_CONF_ERROR;
     }
 
     if (ngx_close_file(fd) == NGX_FILE_ERROR) {
-        ngx_log_error(NGX_LOG_ALERT, cf->log, ngx_errno,
-                      ngx_close_file_n " %s failed", file.data);
+        ngx_conf_log_error(NGX_LOG_EMERG, cf, ngx_errno,
+                           ngx_close_file_n " %s failed", file.data);
     }
 
     end = start + size;


More information about the nginx-devel mailing list