/src/h2o/lib/handler/configurator/h2olog.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2022 Fastly, Inc., Goro Fuji, Kazuho Oku |
3 | | * |
4 | | * Permission is hereby granted, free of charge, to any person obtaining a copy |
5 | | * of this software and associated documentation files (the "Software"), to |
6 | | * deal in the Software without restriction, including without limitation the |
7 | | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
8 | | * sell copies of the Software, and to permit persons to whom the Software is |
9 | | * furnished to do so, subject to the following conditions: |
10 | | * |
11 | | * The above copyright notice and this permission notice shall be included in |
12 | | * all copies or substantial portions of the Software. |
13 | | * |
14 | | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
15 | | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
16 | | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
17 | | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
18 | | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
19 | | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS |
20 | | * IN THE SOFTWARE. |
21 | | */ |
22 | | #include "h2o.h" |
23 | | #include "h2o/configurator.h" |
24 | | #include "yoml-parser.h" |
25 | | |
26 | | static int on_config_h2olog(h2o_configurator_command_t *cmd, h2o_configurator_context_t *ctx, yoml_t *node) |
27 | 0 | { |
28 | 0 | assert(node->type == YOML_TYPE_SCALAR); |
29 | | |
30 | 0 | switch (h2o_configurator_get_one_of(cmd, node, "OFF,ON,appdata")) { |
31 | 0 | case 0: /* OFF */ |
32 | 0 | return 0; |
33 | 0 | case 1: /* ON */ |
34 | 0 | break; |
35 | 0 | case 2: /* appdata */ |
36 | 0 | ptls_log.may_include_appdata = 1; |
37 | 0 | break; |
38 | 0 | default: |
39 | 0 | return -1; |
40 | 0 | } |
41 | | |
42 | 0 | h2o_log_register(ctx->hostconf); |
43 | 0 | return 0; |
44 | 0 | } |
45 | | |
46 | | void h2o_log_register_configurator(h2o_globalconf_t *conf) |
47 | 0 | { |
48 | 0 | h2o_configurator_t *c = h2o_configurator_create(conf, sizeof(*c)); |
49 | 0 | h2o_configurator_define_command(c, "h2olog", H2O_CONFIGURATOR_FLAG_HOST | H2O_CONFIGURATOR_FLAG_EXPECT_SCALAR, |
50 | 0 | on_config_h2olog); |
51 | 0 | } |