Debian Codegraph @

lib/proc/proc_log.c

raw symbols SCIP
1 /*
2 Copyright(C) 2009-2018 Brazil
3 Copyright(C) 2021 Sutou Kouhei <[email protected]>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #include "../grn_ctx.h"cxx . . $ `<file>/lib/grn_ctx.h`/
21 #include "../grn_output.h"cxx . . $ `<file>/lib/grn_output.h`/
22 #include "../grn_proc.h"cxx . . $ `<file>/lib/grn_proc.h`/
23
24 #include <groonga/plugin.h>cxx . . $ `<file>/include/groonga/plugin.h`/
25
26 static grn_objcxx . . $ grn_obj# *
27 command_log_levelcxx . . $ command_log_level(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
28 int n_args,
29 grn_objcxx . . $ grn_obj# **args,
30 grn_user_datacxx . . $ grn_user_data# *user_data)
31 {
32 grn_objcxx . . $ grn_obj# *level_name = grn_plugin_proc_get_varcxx . . $ grn_plugin_proc_get_var(3074f8d72b0d40ab).(ctx,
33 user_data,
34 "level", -1);
35 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(level_name) > 0) {
36 grn_log_levelcxx . . $ grn_log_level# max_level;
37 GRN_TEXT_PUTCcxx . . $ `include/groonga/groonga.h:2775:9`!(ctx, level_name, '\0');
38 if (grn_log_level_parsecxx . . $ grn_log_level_parse(ade47491a90ed684).(GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(level_name), &max_level)) {
39 grn_logger_set_max_levelcxx . . $ grn_logger_set_max_level(59adfd980b109eb9).(ctx, max_level);
40 } else {
41 ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT,
42 "invalid log level: <%s>", GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(level_name));
43 }
44 } else {
45 ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT, "log level is missing");
46 }
47 GRN_OUTPUT_BOOLcxx . . $ `lib/grn_output.h:108:9`!(ctx->rc == GRN_SUCCESS);
48 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
49 }
50
51 void
52 grn_proc_init_log_levelcxx . . $ grn_proc_init_log_level(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx)
53 {
54 grn_expr_varcxx . . $ grn_expr_var# vars[1];
55 grn_plugin_expr_var_initcxx . . $ grn_plugin_expr_var_init(680ef4125f11597f).(ctx, &(vars[0]), "level", -1);
56 grn_plugin_command_createcxx . . $ grn_plugin_command_create(2dfd920bb40f3149).(ctx,
57 "log_level", -1,
58 command_log_levelcxx . . $ command_log_level(fd082858389c8bb0).,
59 1,
60 vars);
61 }
62
63 static grn_objcxx . . $ grn_obj# *
64 command_log_putcxx . . $ command_log_put(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
65 int n_args,
66 grn_objcxx . . $ grn_obj# **args,
67 grn_user_datacxx . . $ grn_user_data# *user_data)
68 {
69 grn_objcxx . . $ grn_obj# *level_name = grn_plugin_proc_get_varcxx . . $ grn_plugin_proc_get_var(3074f8d72b0d40ab).(ctx,
70 user_data,
71 "level", -1);
72 grn_objcxx . . $ grn_obj# *message = grn_plugin_proc_get_varcxx . . $ grn_plugin_proc_get_var(3074f8d72b0d40ab).(ctx,
73 user_data,
74 "message", -1);
75 if (GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(level_name) > 0) {
76 grn_log_levelcxx . . $ grn_log_level# level;
77 GRN_TEXT_PUTCcxx . . $ `include/groonga/groonga.h:2775:9`!(ctx, level_name, '\0');
78 if (grn_log_level_parsecxx . . $ grn_log_level_parse(ade47491a90ed684).(GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(level_name), &level)) {
79 GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, level, "%.*s",
80 (int)GRN_TEXT_LENcxx . . $ `include/groonga/groonga.h:2786:9`!(message),
81 GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(message));
82 } else {
83 ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT,
84 "invalid log level: <%s>", GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(level_name));
85 }
86 } else {
87 ERRcxx . . $ `lib/grn_error.h:156:9`!(GRN_INVALID_ARGUMENT, "log level is missing");
88 }
89 GRN_OUTPUT_BOOLcxx . . $ `lib/grn_output.h:108:9`!(ctx->rc == GRN_SUCCESS);
90 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
91 }
92
93 void
94 grn_proc_init_log_putcxx . . $ grn_proc_init_log_put(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx)
95 {
96 grn_expr_varcxx . . $ grn_expr_var# vars[2];
97 grn_plugin_expr_var_initcxx . . $ grn_plugin_expr_var_init(680ef4125f11597f).(ctx, &(vars[0]), "level", -1);
98 grn_plugin_expr_var_initcxx . . $ grn_plugin_expr_var_init(680ef4125f11597f).(ctx, &(vars[1]), "message", -1);
99 grn_plugin_command_createcxx . . $ grn_plugin_command_create(2dfd920bb40f3149).(ctx,
100 "log_put", -1,
101 command_log_putcxx . . $ command_log_put(fd082858389c8bb0).,
102 2,
103 vars);
104 }
105
106 static grn_objcxx . . $ grn_obj# *
107 command_log_reopencxx . . $ command_log_reopen(fd082858389c8bb0).(grn_ctxcxx . . $ grn_ctx# *ctx,
108 int n_args,
109 grn_objcxx . . $ grn_obj# **args,
110 grn_user_datacxx . . $ grn_user_data# *user_data)
111 {
112 grn_log_reopencxx . . $ grn_log_reopen(b578cd6e53d5fe91).(ctx);
113 GRN_OUTPUT_BOOLcxx . . $ `lib/grn_output.h:108:9`!(ctx->rc == GRN_SUCCESS);
114 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!;
115 }
116
117 void
118 grn_proc_init_log_reopencxx . . $ grn_proc_init_log_reopen(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx)
119 {
120 grn_plugin_command_createcxx . . $ grn_plugin_command_create(2dfd920bb40f3149).(ctx,
121 "log_reopen", -1,
122 command_log_reopencxx . . $ command_log_reopen(fd082858389c8bb0).,
123 0,
124 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!);
125 }