-
Notifications
You must be signed in to change notification settings - Fork 1
Add ws_log_format message directive #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
87ef992 to
e6e5a3a
Compare
b2b2c08 to
3a9799c
Compare
Add message template
3a9799c to
543c013
Compare
Signed-off-by: Anton Zaslavskiy <anton.zaslavskiy@chainstack.com>
ngx_http_websocket_stat_module.c
Outdated
| { | ||
| template_ctx_s *ctx = data; | ||
| ngx_frame_counter_t *frame_cntr = &ctx->ws_ctx->frame_counter; | ||
| if (!ctx || !frame_cntr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UB: you already dereferenced ctx, so it cannot be null here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for that! I will change the condition as well as specify types of the arguments explicitly
UPD: can't change signatures of the functions as it will require significant refactoring
ngx_http_websocket_stat_module.c
Outdated
| ngx_http_websocket_srv_conf_t *srvcf; | ||
|
|
||
| srvcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_websocket_srv_conf_t)); | ||
| if (srvcf == NULL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Earlier pointers were checked for null by simple negation. Don't you want to be consistent?
ngx_http_websocket_stat_module.c
Outdated
| if (conf->enabled && !conf->ws_log) { | ||
| init_ws_log_file(cf, conf, &cf->cycle->error_log); | ||
| } | ||
|
|
||
| if (conf->enabled && !conf->ws_log) | ||
| return NGX_CONF_ERROR; | ||
|
|
||
| if (conf->enabled && !conf->ws_log->file) | ||
| return NGX_CONF_ERROR; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (conf->enabled && !conf->ws_log) { | |
| init_ws_log_file(cf, conf, &cf->cycle->error_log); | |
| } | |
| if (conf->enabled && !conf->ws_log) | |
| return NGX_CONF_ERROR; | |
| if (conf->enabled && !conf->ws_log->file) | |
| return NGX_CONF_ERROR; | |
| if (conf->enabled && !conf->ws_log) { | |
| init_ws_log_file(cf, conf, &cf->cycle->error_log); | |
| if (!conf->ws_log || !conf->ws_log->file) | |
| return NGX_CONF_ERROR; | |
| } |
Signed-off-by: Anton Zaslavskiy <anton.zaslavskiy@chainstack.com>
30eae27 to
a08eee5
Compare
Co-authored-by: Alexey Gerasimov <lokomot476@gmail.com>
ws_log_format "message"directive to log full messages, not chunks. Logged all non-control frames (https://tools.ietf.org/html/rfc6455#section-5.2).ws_log_enabledto disable/enable module for the server blockws_message_sizetemplate variableSome issues:
Example configuration
Links:
https://tools.ietf.org/html/rfc6455#section-5.2
http://nginx.org/en/docs/dev/development_guide.html#http_conf