| 1 | /* |
| 2 | Copyright (C) 2009-2017 Brazil |
| 3 | Copyright (C) 2018-2024 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_logger.h"cxx . . $ `<file>/lib/grn_logger.h`/ |
| 21 | #include "grn_ctx.h"cxx . . $ `<file>/lib/grn_ctx.h`/ |
| 22 | #include "grn_ctx_impl.h"cxx . . $ `<file>/lib/grn_ctx_impl.h`/ |
| 23 | |
| 24 | #include <stdio.h> |
| 25 | #include <string.h> |
| 26 | #include <sys/stat.h> |
| 27 | |
| 28 | #ifdef WIN32 |
| 29 | # include <share.h> |
| 30 | #else /* WIN32 */ |
| 31 | # include <sys/file.h> |
| 32 | #endif /* WIN32 */ |
| 33 | |
| 34 | static const char *log_level_namescxx . . $ log_level_names.[] = { |
| 35 | "none", |
| 36 | "emergency", |
| 37 | "alert", |
| 38 | "critical", |
| 39 | "error", |
| 40 | "warning", |
| 41 | "notice", |
| 42 | "info", |
| 43 | "debug", |
| 44 | "dump" |
| 45 | }; |
| 46 | |
| 47 | #define GRN_LOG_LASTcxx . . $ `lib/logger.c:47:9`! GRN_LOG_DUMP |
| 48 | |
| 49 | typedef enumcxx . . $ $anonymous_type_99e57209684e9df1_0# { |
| 50 | GRN_FLAGS_OPERATOR_ADDcxx . . $ GRN_FLAGS_OPERATOR_ADD., |
| 51 | GRN_FLAGS_OPERATOR_REMOVEcxx . . $ GRN_FLAGS_OPERATOR_REMOVE., |
| 52 | GRN_FLAGS_OPERATOR_REPLACEcxx . . $ GRN_FLAGS_OPERATOR_REPLACE., |
| 53 | } grn_flags_operatorcxx . . $ grn_flags_operator#; |
| 54 | |
| 55 | #define INITIAL_LOGGERcxx . . $ `lib/logger.c:55:9`! { \ |
| 56 | GRN_LOG_DEFAULT_LEVELcxx . . $ `include/groonga/groonga.h:2473:11`!, \ |
| 57 | GRN_LOG_DEFAULTcxx . . $ `include/groonga/groonga.h:2376:9`!, \ |
| 58 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, \ |
| 59 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, \ |
| 60 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, \ |
| 61 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! \ |
| 62 | } |
| 63 | |
| 64 | static grn_loggercxx . . $ grn_logger# current_loggercxx . . $ current_logger. = INITIAL_LOGGERcxx . . $ `lib/logger.c:55:9`!; |
| 65 | |
| 66 | const char * |
| 67 | grn_log_level_to_stringcxx . . $ grn_log_level_to_string(e273248267cc0d14).(grn_log_levelcxx . . $ grn_log_level# level) |
| 68 | { |
| 69 | if (level <= GRN_LOG_LASTcxx . . $ `lib/logger.c:47:9`!) { |
| 70 | return log_level_namescxx . . $ log_level_names.[level]; |
| 71 | } else { |
| 72 | return "unknown"; |
| 73 | } |
| 74 | } |
| 75 | |
| 76 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! |
| 77 | grn_log_level_parsecxx . . $ grn_log_level_parse(ade47491a90ed684).(const char *string, grn_log_levelcxx . . $ grn_log_level# *level) |
| 78 | { |
| 79 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(string, " ") == 0 || |
| 80 | grn_strcasecmpcxx . . $ `include/groonga/portability.h:120:11`!(string, "none") == 0) { |
| 81 | *level = GRN_LOG_NONEcxx . . $ `include/groonga/groonga.h:2362:9`!; |
| 82 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 83 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(string, "E") == 0 || |
| 84 | grn_strcasecmpcxx . . $ `include/groonga/portability.h:120:11`!(string, "emerg") == 0 || |
| 85 | grn_strcasecmpcxx . . $ `include/groonga/portability.h:120:11`!(string, "emergency") == 0) { |
| 86 | *level = GRN_LOG_EMERGcxx . . $ GRN_LOG_EMERG.; |
| 87 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 88 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(string, "A") == 0 || |
| 89 | grn_strcasecmpcxx . . $ `include/groonga/portability.h:120:11`!(string, "alert") == 0) { |
| 90 | *level = GRN_LOG_ALERTcxx . . $ GRN_LOG_ALERT.; |
| 91 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 92 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(string, "C") == 0 || |
| 93 | grn_strcasecmpcxx . . $ `include/groonga/portability.h:120:11`!(string, "crit") == 0 || |
| 94 | grn_strcasecmpcxx . . $ `include/groonga/portability.h:120:11`!(string, "critical") == 0) { |
| 95 | *level = GRN_LOG_CRITcxx . . $ GRN_LOG_CRIT.; |
| 96 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 97 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(string, "e") == 0 || |
| 98 | grn_strcasecmpcxx . . $ `include/groonga/portability.h:120:11`!(string, "error") == 0) { |
| 99 | *level = GRN_LOG_ERRORcxx . . $ GRN_LOG_ERROR.; |
| 100 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 101 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(string, "w") == 0 || |
| 102 | grn_strcasecmpcxx . . $ `include/groonga/portability.h:120:11`!(string, "warn") == 0 || |
| 103 | grn_strcasecmpcxx . . $ `include/groonga/portability.h:120:11`!(string, "warning") == 0) { |
| 104 | *level = GRN_LOG_WARNINGcxx . . $ GRN_LOG_WARNING.; |
| 105 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 106 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(string, "n") == 0 || |
| 107 | grn_strcasecmpcxx . . $ `include/groonga/portability.h:120:11`!(string, "notice") == 0) { |
| 108 | *level = GRN_LOG_NOTICEcxx . . $ GRN_LOG_NOTICE.; |
| 109 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 110 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(string, "i") == 0 || |
| 111 | grn_strcasecmpcxx . . $ `include/groonga/portability.h:120:11`!(string, "info") == 0) { |
| 112 | *level = GRN_LOG_INFOcxx . . $ GRN_LOG_INFO.; |
| 113 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 114 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(string, "d") == 0 || |
| 115 | grn_strcasecmpcxx . . $ `include/groonga/portability.h:120:11`!(string, "debug") == 0) { |
| 116 | *level = GRN_LOG_DEBUGcxx . . $ GRN_LOG_DEBUG.; |
| 117 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 118 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(string, "-") == 0 || |
| 119 | grn_strcasecmpcxx . . $ `include/groonga/portability.h:120:11`!(string, "dump") == 0) { |
| 120 | *level = GRN_LOG_DUMPcxx . . $ GRN_LOG_DUMP.; |
| 121 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 122 | } |
| 123 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 124 | } |
| 125 | |
| 126 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! |
| 127 | grn_log_flags_parsecxx . . $ grn_log_flags_parse(1a0a5fdf16ca07b0).(const char *string, |
| 128 | int string_size, |
| 129 | int *flags) |
| 130 | { |
| 131 | const char *string_end; |
| 132 | |
| 133 | *flags = GRN_LOG_DEFAULTcxx . . $ `include/groonga/groonga.h:2376:9`!; |
| 134 | |
| 135 | if (!string) { |
| 136 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 137 | } |
| 138 | |
| 139 | if (string_size < 0) { |
| 140 | string_size = (int)strlencxx . . $ strlen(751346f8406fd082).(string); |
| 141 | } |
| 142 | |
| 143 | string_end = string + string_size; |
| 144 | |
| 145 | while (string < string_end) { |
| 146 | grn_flags_operatorcxx . . $ grn_flags_operator# operator = GRN_FLAGS_OPERATOR_REPLACEcxx . . $ GRN_FLAGS_OPERATOR_REPLACE.; |
| 147 | |
| 148 | if (*string == '|' || *string == ' ') { |
| 149 | string += 1; |
| 150 | continue; |
| 151 | } |
| 152 | |
| 153 | if (*string == '+') { |
| 154 | operator = GRN_FLAGS_OPERATOR_ADDcxx . . $ GRN_FLAGS_OPERATOR_ADD.; |
| 155 | string++; |
| 156 | } else if (*string == '-') { |
| 157 | operator = GRN_FLAGS_OPERATOR_REMOVEcxx . . $ GRN_FLAGS_OPERATOR_REMOVE.; |
| 158 | string++; |
| 159 | } |
| 160 | |
| 161 | #define CHECK_FLAGcxx . . $ `lib/logger.c:161:9`!(name) \ |
| 162 | if (((size_t)(string_end - string) >= (sizeof(#name) - 1)) && \ |
| 163 | (grn_strncasecmpcxx . . $ `include/groonga/portability.h:127:11`!(string, #name, sizeof(#name) - 1) == 0) && \ |
| 164 | (((size_t)(string_end - string) == (sizeof(#name) - 1)) || \ |
| 165 | (string[sizeof(#name) - 1] == '|') || \ |
| 166 | (string[sizeof(#name) - 1] == ' ') || \ |
| 167 | (string[sizeof(#name) - 1] == '+') || \ |
| 168 | (string[sizeof(#name) - 1] == '-'))) { \ |
| 169 | if (operator == GRN_FLAGS_OPERATOR_ADD) { \ |
| 170 | *flags |= GRN_LOG_ ## name; \ |
| 171 | } else if (operator == GRN_FLAGS_OPERATOR_REMOVE) { \ |
| 172 | *flags &= ~GRN_LOG_ ## name; \ |
| 173 | } else { \ |
| 174 | *flags = GRN_LOG_ ## name; \ |
| 175 | } \ |
| 176 | string += sizeof(#name) - 1; \ |
| 177 | continue; \ |
| 178 | } |
| 179 | |
| 180 | CHECK_FLAGcxx . . $ `lib/logger.c:161:9`!(NONE); |
| 181 | CHECK_FLAGcxx . . $ `lib/logger.c:161:9`!(TIME); |
| 182 | CHECK_FLAGcxx . . $ `lib/logger.c:161:9`!(TITLE); |
| 183 | CHECK_FLAGcxx . . $ `lib/logger.c:161:9`!(MESSAGE); |
| 184 | CHECK_FLAGcxx . . $ `lib/logger.c:161:9`!(LOCATION); |
| 185 | CHECK_FLAGcxx . . $ `lib/logger.c:161:9`!(PID); |
| 186 | CHECK_FLAGcxx . . $ `lib/logger.c:161:9`!(PROCESS_ID); |
| 187 | CHECK_FLAGcxx . . $ `lib/logger.c:161:9`!(THREAD_ID); |
| 188 | CHECK_FLAGcxx . . $ `lib/logger.c:161:9`!(CTX_ID); |
| 189 | CHECK_FLAGcxx . . $ `lib/logger.c:161:9`!(CONTEXT_ID); |
| 190 | CHECK_FLAGcxx . . $ `lib/logger.c:161:9`!(ALL); |
| 191 | CHECK_FLAGcxx . . $ `lib/logger.c:161:9`!(DEFAULT); |
| 192 | |
| 193 | #undef CHECK_FLAGcxx . . $ `lib/logger.c:161:9`! |
| 194 | |
| 195 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 196 | } |
| 197 | |
| 198 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 199 | } |
| 200 | |
| 201 | typedef structcxx . . $ $anonymous_type_99e57209684e9df1_1# { |
| 202 | char *pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path.; |
| 203 | FILEcxx . . $ FILE# *filecxx . . $ $anonymous_type_99e57209684e9df1_1#file.; |
| 204 | grn_critical_sectioncxx . . $ grn_critical_section# lockcxx . . $ $anonymous_type_99e57209684e9df1_1#lock.; |
| 205 | off_tcxx . . $ off_t# sizecxx . . $ $anonymous_type_99e57209684e9df1_1#size.; |
| 206 | off_tcxx . . $ off_t# rotate_threshold_sizecxx . . $ $anonymous_type_99e57209684e9df1_1#rotate_threshold_size.; |
| 207 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! need_flockcxx . . $ $anonymous_type_99e57209684e9df1_1#need_flock.; |
| 208 | } grn_logger_outputcxx . . $ grn_logger_output#; |
| 209 | |
| 210 | static void |
| 211 | grn_logger_output_initcxx . . $ grn_logger_output_init(a726f2281954d2f4).(grn_logger_outputcxx . . $ grn_logger_output# *output) |
| 212 | { |
| 213 | CRITICAL_SECTION_INITcxx . . $ `lib/grn.h:226:11`!(output->lock); |
| 214 | } |
| 215 | |
| 216 | static void |
| 217 | grn_logger_output_closecxx . . $ grn_logger_output_close(1d8c945b22d5ac23).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_logger_outputcxx . . $ grn_logger_output# *output) |
| 218 | { |
| 219 | CRITICAL_SECTION_ENTERcxx . . $ `lib/grn.h:227:11`!(output->lock); |
| 220 | if (output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file.) { |
| 221 | if (output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file. != stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`! && |
| 222 | output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file. != stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!) { |
| 223 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file.); |
| 224 | } |
| 225 | output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 226 | } |
| 227 | CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(output->lock); |
| 228 | } |
| 229 | |
| 230 | static void |
| 231 | grn_logger_output_fincxx . . $ grn_logger_output_fin(1d8c945b22d5ac23).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_logger_outputcxx . . $ grn_logger_output# *output) |
| 232 | { |
| 233 | grn_logger_output_closecxx . . $ grn_logger_output_close(1d8c945b22d5ac23).(ctx, output); |
| 234 | if (output->pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path.) { |
| 235 | freecxx . . $ free(5d22bdacc48458e8).(output->pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path.); |
| 236 | output->pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 237 | } |
| 238 | CRITICAL_SECTION_FINcxx . . $ `lib/grn.h:229:11`!(output->lock); |
| 239 | } |
| 240 | |
| 241 | static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! |
| 242 | grn_logger_output_startcxx . . $ grn_logger_output_start(6ecbd6d13493afa7).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 243 | grn_logger_outputcxx . . $ grn_logger_output# *output, |
| 244 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! need_flock) |
| 245 | { |
| 246 | if (!output->pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path.) { |
| 247 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 248 | } |
| 249 | |
| 250 | CRITICAL_SECTION_ENTERcxx . . $ `lib/grn.h:227:11`!(output->lock); |
| 251 | |
| 252 | if (!output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file.) { |
| 253 | output->sizecxx . . $ $anonymous_type_99e57209684e9df1_1#size. = 0; |
| 254 | if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(output->pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path., "-") == 0) { |
| 255 | output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file. = stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`!; |
| 256 | } else if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(output->pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path., "+") == 0) { |
| 257 | output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file. = stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!; |
| 258 | } else { |
| 259 | output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file. = grn_fopencxx . . $ `include/groonga/portability.h:76:11`!(output->path, "a"); |
| 260 | if (output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file.) { |
| 261 | struct statcxx . . $ stat# stat; |
| 262 | if (fstatcxx . . $ fstat(a43660ce2f600cb5).(grn_filenocxx . . $ `include/groonga/portability.h:185:11`!(output->file), &stat) != -1) { |
| 263 | output->sizecxx . . $ $anonymous_type_99e57209684e9df1_1#size. = stat.st_sizecxx . . $ stat#st_size.; |
| 264 | } |
| 265 | } |
| 266 | } |
| 267 | } |
| 268 | |
| 269 | if (!output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file.) { |
| 270 | CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(output->lock); |
| 271 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 272 | } |
| 273 | |
| 274 | output->need_flockcxx . . $ $anonymous_type_99e57209684e9df1_1#need_flock. = need_flock; |
| 275 | if (output->need_flockcxx . . $ $anonymous_type_99e57209684e9df1_1#need_flock.) { |
| 276 | if (output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file. == stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`! || |
| 277 | output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file. == stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!) { |
| 278 | output->need_flockcxx . . $ $anonymous_type_99e57209684e9df1_1#need_flock. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 279 | #ifndef _WIN32 |
| 280 | } else if (flockcxx . . $ flock(9b79fb6aee4c0440).(filenocxx . . $ fileno(89bc1efcdac0ca22).(output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file.), LOCK_EXcxx . . $ `<external>/8566841665215861632/file.h:41:9`!) == -1) { |
| 281 | output->need_flockcxx . . $ $anonymous_type_99e57209684e9df1_1#need_flock. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 282 | #endif |
| 283 | } |
| 284 | } |
| 285 | |
| 286 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 287 | } |
| 288 | |
| 289 | static void |
| 290 | grn_logger_output_rotatecxx . . $ grn_logger_output_rotate(1d8c945b22d5ac23).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_logger_outputcxx . . $ grn_logger_output# *output) |
| 291 | { |
| 292 | char rotated_path[PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!]; |
| 293 | grn_timevalcxx . . $ grn_timeval# now; |
| 294 | struct tmcxx . . $ tm# tm_buffer; |
| 295 | struct tmcxx . . $ tm# *tm; |
| 296 | |
| 297 | grn_timeval_nowcxx . . $ grn_timeval_now(b116eeadcb699bd1).(ctx, &now); |
| 298 | tm = grn_timeval2tmcxx . . $ grn_timeval2tm(17aa9e83661c23e4).(ctx, &now, &tm_buffer); |
| 299 | grn_snprintfcxx . . $ `include/groonga/portability.h:137:11`!(rotated_path, PATH_MAX, PATH_MAXcxx . . $ `<external>/6347054901304145714/limits.h:13:9`!, |
| 300 | "%s.%04d-%02d-%02d-%02d-%02d-%02d-%06d", |
| 301 | output->path, |
| 302 | tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, |
| 303 | tm->tm_hour, tm->tm_min, tm->tm_sec, |
| 304 | (int)(GRN_TIME_NSEC_TO_USECcxx . . $ `include/groonga/time.h:39:9`!(now.tv_nsec))); |
| 305 | renamecxx . . $ rename(5ae29d726ae57f88).(output->pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path., rotated_path); |
| 306 | } |
| 307 | |
| 308 | static void |
| 309 | grn_logger_output_endcxx . . $ grn_logger_output_end(56c9afbf588437a).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 310 | grn_logger_outputcxx . . $ grn_logger_output# *output, |
| 311 | int written) |
| 312 | { |
| 313 | if (written > 0) { |
| 314 | output->sizecxx . . $ $anonymous_type_99e57209684e9df1_1#size. += written; |
| 315 | if (output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file. != stdoutcxx . . $ `<external>/232824719582829767/stdio.h:158:9`! && |
| 316 | output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file. != stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`! && |
| 317 | (output->rotate_threshold_sizecxx . . $ $anonymous_type_99e57209684e9df1_1#rotate_threshold_size. > 0 && |
| 318 | output->sizecxx . . $ $anonymous_type_99e57209684e9df1_1#size. >= output->rotate_threshold_sizecxx . . $ $anonymous_type_99e57209684e9df1_1#rotate_threshold_size.)) { |
| 319 | #ifndef _WIN32 |
| 320 | if (output->need_flockcxx . . $ $anonymous_type_99e57209684e9df1_1#need_flock.) { |
| 321 | flockcxx . . $ flock(9b79fb6aee4c0440).(filenocxx . . $ fileno(89bc1efcdac0ca22).(output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file.), LOCK_UNcxx . . $ `<external>/8566841665215861632/file.h:42:9`!); |
| 322 | } |
| 323 | #endif |
| 324 | fclosecxx . . $ fclose(89bc1efcdac0ca22).(output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file.); |
| 325 | output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 326 | grn_logger_output_rotatecxx . . $ grn_logger_output_rotate(1d8c945b22d5ac23).(ctx, output); |
| 327 | } else { |
| 328 | fflushcxx . . $ fflush(89bc1efcdac0ca22).(output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file.); |
| 329 | } |
| 330 | } |
| 331 | #ifndef _WIN32 |
| 332 | if (output->need_flockcxx . . $ $anonymous_type_99e57209684e9df1_1#need_flock. && output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file.) { |
| 333 | flockcxx . . $ flock(9b79fb6aee4c0440).(filenocxx . . $ fileno(89bc1efcdac0ca22).(output->filecxx . . $ $anonymous_type_99e57209684e9df1_1#file.), LOCK_UNcxx . . $ `<external>/8566841665215861632/file.h:42:9`!); |
| 334 | } |
| 335 | #endif |
| 336 | |
| 337 | CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(output->lock); |
| 338 | } |
| 339 | |
| 340 | static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! logger_initedcxx . . $ logger_inited. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 341 | static grn_logger_outputcxx . . $ grn_logger_output# default_logger_outputcxx . . $ default_logger_output. = {0}; |
| 342 | |
| 343 | static void |
| 344 | default_logger_logcxx . . $ default_logger_log(4382505f96719c86).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_log_levelcxx . . $ grn_log_level# level, |
| 345 | const char *timestamp, const char *title, |
| 346 | const char *message, const char *location, void *user_data) |
| 347 | { |
| 348 | if (!grn_logger_output_startcxx . . $ grn_logger_output_start(6ecbd6d13493afa7).(ctx, |
| 349 | &default_logger_outputcxx . . $ default_logger_output., |
| 350 | (current_loggercxx . . $ current_logger..flagscxx . . $ _grn_logger#flags. & GRN_LOG_PIDcxx . . $ `include/groonga/groonga.h:2367:9`!))) { |
| 351 | return; |
| 352 | } |
| 353 | |
| 354 | const char slev[] = " EACewnid-"; |
| 355 | char label = *(slev + level); |
| 356 | int written = 0; |
| 357 | if (location && *location) { |
| 358 | if (title && *title) { |
| 359 | written = fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(default_logger_outputcxx . . $ default_logger_output..filecxx . . $ $anonymous_type_99e57209684e9df1_1#file., "%s|%c|%s: %s %s\n", |
| 360 | timestamp, label, location, title, message); |
| 361 | } else { |
| 362 | written = fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(default_logger_outputcxx . . $ default_logger_output..filecxx . . $ $anonymous_type_99e57209684e9df1_1#file., "%s|%c|%s: %s\n", |
| 363 | timestamp, label, location, message); |
| 364 | } |
| 365 | } else { |
| 366 | written = fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(default_logger_outputcxx . . $ default_logger_output..filecxx . . $ $anonymous_type_99e57209684e9df1_1#file., "%s|%c|%s %s\n", |
| 367 | timestamp, label, title, message); |
| 368 | } |
| 369 | |
| 370 | grn_logger_output_endcxx . . $ grn_logger_output_end(56c9afbf588437a).(ctx, &default_logger_outputcxx . . $ default_logger_output., written); |
| 371 | } |
| 372 | |
| 373 | static void |
| 374 | default_logger_reopencxx . . $ default_logger_reopen(b6b6153f622d9caa).(grn_ctxcxx . . $ grn_ctx# *ctx, void *user_data) |
| 375 | { |
| 376 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_DEBUG, "log will be closed."); |
| 377 | grn_logger_output_closecxx . . $ grn_logger_output_close(1d8c945b22d5ac23).(ctx, &default_logger_outputcxx . . $ default_logger_output.); |
| 378 | GRN_LOGcxx . . $ `include/groonga/groonga.h:2493:9`!(ctx, GRN_LOG_DEBUG, "log opened."); |
| 379 | } |
| 380 | |
| 381 | static void |
| 382 | default_logger_fincxx . . $ default_logger_fin(b6b6153f622d9caa).(grn_ctxcxx . . $ grn_ctx# *ctx, void *user_data) |
| 383 | { |
| 384 | if (!logger_initedcxx . . $ logger_inited.) { |
| 385 | return; |
| 386 | } |
| 387 | grn_logger_output_closecxx . . $ grn_logger_output_close(1d8c945b22d5ac23).(ctx, &default_logger_outputcxx . . $ default_logger_output.); |
| 388 | } |
| 389 | |
| 390 | static grn_loggercxx . . $ grn_logger# default_loggercxx . . $ default_logger. = { |
| 391 | GRN_LOG_DEFAULT_LEVELcxx . . $ `include/groonga/groonga.h:2473:11`!, |
| 392 | GRN_LOG_DEFAULTcxx . . $ `include/groonga/groonga.h:2376:9`!, |
| 393 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 394 | default_logger_logcxx . . $ default_logger_log(4382505f96719c86)., |
| 395 | default_logger_reopencxx . . $ default_logger_reopen(b6b6153f622d9caa)., |
| 396 | default_logger_fincxx . . $ default_logger_fin(b6b6153f622d9caa). |
| 397 | }; |
| 398 | |
| 399 | void |
| 400 | grn_default_logger_set_max_levelcxx . . $ grn_default_logger_set_max_level(f9d277a447c2c34d).(grn_log_levelcxx . . $ grn_log_level# max_level) |
| 401 | { |
| 402 | default_loggercxx . . $ default_logger..max_levelcxx . . $ _grn_logger#max_level. = max_level; |
| 403 | if (current_loggercxx . . $ current_logger..logcxx . . $ _grn_logger#log. == default_logger_logcxx . . $ default_logger_log(4382505f96719c86).) { |
| 404 | current_loggercxx . . $ current_logger..max_levelcxx . . $ _grn_logger#max_level. = max_level; |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | grn_log_levelcxx . . $ grn_log_level# |
| 409 | grn_default_logger_get_max_levelcxx . . $ grn_default_logger_get_max_level(992d95faad553eb).(void) |
| 410 | { |
| 411 | return default_loggercxx . . $ default_logger..max_levelcxx . . $ _grn_logger#max_level.; |
| 412 | } |
| 413 | |
| 414 | void |
| 415 | grn_default_logger_set_flagscxx . . $ grn_default_logger_set_flags(d4f767463ce0a6b3).(int flags) |
| 416 | { |
| 417 | default_loggercxx . . $ default_logger..flagscxx . . $ _grn_logger#flags. = flags; |
| 418 | if (current_loggercxx . . $ current_logger..logcxx . . $ _grn_logger#log. == default_logger_logcxx . . $ default_logger_log(4382505f96719c86).) { |
| 419 | current_loggercxx . . $ current_logger..flagscxx . . $ _grn_logger#flags. = flags; |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | int |
| 424 | grn_default_logger_get_flagscxx . . $ grn_default_logger_get_flags(b126dc7c1de90089).(void) |
| 425 | { |
| 426 | return default_loggercxx . . $ default_logger..flagscxx . . $ _grn_logger#flags.; |
| 427 | } |
| 428 | |
| 429 | void |
| 430 | grn_default_logger_set_pathcxx . . $ grn_default_logger_set_path(85c52e162fed56f9).(const char *path) |
| 431 | { |
| 432 | if (logger_initedcxx . . $ logger_inited.) { |
| 433 | CRITICAL_SECTION_ENTERcxx . . $ `lib/grn.h:227:11`!(default_logger_output.lock); |
| 434 | } |
| 435 | |
| 436 | if (default_logger_outputcxx . . $ default_logger_output..pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path.) { |
| 437 | freecxx . . $ free(5d22bdacc48458e8).(default_logger_outputcxx . . $ default_logger_output..pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path.); |
| 438 | } |
| 439 | |
| 440 | if (path) { |
| 441 | default_logger_outputcxx . . $ default_logger_output..pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path. = grn_strdup_rawcxx . . $ `include/groonga/portability.h:82:11`!(path); |
| 442 | } else { |
| 443 | default_logger_outputcxx . . $ default_logger_output..pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 444 | } |
| 445 | |
| 446 | if (logger_initedcxx . . $ logger_inited.) { |
| 447 | CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(default_logger_output.lock); |
| 448 | } |
| 449 | } |
| 450 | |
| 451 | const char * |
| 452 | grn_default_logger_get_pathcxx . . $ grn_default_logger_get_path(33a1f659e94feb42).(void) |
| 453 | { |
| 454 | return default_logger_outputcxx . . $ default_logger_output..pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path.; |
| 455 | } |
| 456 | |
| 457 | void |
| 458 | grn_default_logger_set_rotate_threshold_sizecxx . . $ grn_default_logger_set_rotate_threshold_size(1624ee8275b10bda).(off_tcxx . . $ off_t# threshold) |
| 459 | { |
| 460 | default_logger_outputcxx . . $ default_logger_output..rotate_threshold_sizecxx . . $ $anonymous_type_99e57209684e9df1_1#rotate_threshold_size. = threshold; |
| 461 | } |
| 462 | |
| 463 | off_tcxx . . $ off_t# |
| 464 | grn_default_logger_get_rotate_threshold_sizecxx . . $ grn_default_logger_get_rotate_threshold_size(da6335ded91d79c2).(void) |
| 465 | { |
| 466 | return default_logger_outputcxx . . $ default_logger_output..rotate_threshold_sizecxx . . $ $anonymous_type_99e57209684e9df1_1#rotate_threshold_size.; |
| 467 | } |
| 468 | |
| 469 | void |
| 470 | grn_logger_reopencxx . . $ grn_logger_reopen(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 471 | { |
| 472 | if (current_loggercxx . . $ current_logger..reopencxx . . $ _grn_logger#reopen.) { |
| 473 | current_loggercxx . . $ current_logger..reopencxx . . $ _grn_logger#reopen.(ctx, current_loggercxx . . $ current_logger..user_datacxx . . $ _grn_logger#user_data.); |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | static void |
| 478 | current_logger_fincxx . . $ current_logger_fin(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 479 | { |
| 480 | if (current_loggercxx . . $ current_logger..fincxx . . $ _grn_logger#fin.) { |
| 481 | current_loggercxx . . $ current_logger..fincxx . . $ _grn_logger#fin.(ctx, current_loggercxx . . $ current_logger..user_datacxx . . $ _grn_logger#user_data.); |
| 482 | } |
| 483 | { |
| 484 | grn_loggercxx . . $ grn_logger# initial_logger = INITIAL_LOGGERcxx . . $ `lib/logger.c:55:9`!; |
| 485 | current_loggercxx . . $ current_logger. = initial_logger; |
| 486 | } |
| 487 | } |
| 488 | |
| 489 | static void |
| 490 | logger_info_func_wrappercxx . . $ logger_info_func_wrapper(4382505f96719c86).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_log_levelcxx . . $ grn_log_level# level, |
| 491 | const char *timestamp, const char *title, |
| 492 | const char *message, const char *location, |
| 493 | void *user_data) |
| 494 | { |
| 495 | grn_logger_infocxx . . $ grn_logger_info# *info = user_data; |
| 496 | info->funccxx . . $ _grn_logger_info#func.(level, timestamp, title, message, location, info->func_argcxx . . $ _grn_logger_info#func_arg.); |
| 497 | } |
| 498 | |
| 499 | /* Deprecated since 2.1.2. */ |
| 500 | grn_rccxx . . $ grn_rc# |
| 501 | grn_logger_info_setcxx . . $ grn_logger_info_set(6292ecf3a1ef3543).(grn_ctxcxx . . $ grn_ctx# *ctx, const grn_logger_infocxx . . $ grn_logger_info# *info) |
| 502 | { |
| 503 | if (info) { |
| 504 | grn_loggercxx . . $ grn_logger# logger; |
| 505 | |
| 506 | memsetcxx . . $ memset(d1de1e4fb215f1c6).(&logger, 0, sizeof(grn_loggercxx . . $ grn_logger#)); |
| 507 | logger.max_levelcxx . . $ _grn_logger#max_level. = info->max_levelcxx . . $ _grn_logger_info#max_level.; |
| 508 | logger.flagscxx . . $ _grn_logger#flags. = info->flagscxx . . $ _grn_logger_info#flags.; |
| 509 | if (info->funccxx . . $ _grn_logger_info#func.) { |
| 510 | logger.logcxx . . $ _grn_logger#log. = logger_info_func_wrappercxx . . $ logger_info_func_wrapper(4382505f96719c86).; |
| 511 | logger.user_datacxx . . $ _grn_logger#user_data. = (grn_logger_infocxx . . $ grn_logger_info# *)info; |
| 512 | } else { |
| 513 | logger.logcxx . . $ _grn_logger#log. = default_logger_logcxx . . $ default_logger_log(4382505f96719c86).; |
| 514 | logger.reopencxx . . $ _grn_logger#reopen. = default_logger_reopencxx . . $ default_logger_reopen(b6b6153f622d9caa).; |
| 515 | logger.fincxx . . $ _grn_logger#fin. = default_logger_fincxx . . $ default_logger_fin(b6b6153f622d9caa).; |
| 516 | } |
| 517 | return grn_logger_setcxx . . $ grn_logger_set(937c97a7242c3be2).(ctx, &logger); |
| 518 | } else { |
| 519 | return grn_logger_setcxx . . $ grn_logger_set(937c97a7242c3be2).(ctx, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!); |
| 520 | } |
| 521 | } |
| 522 | |
| 523 | grn_rccxx . . $ grn_rc# |
| 524 | grn_logger_setcxx . . $ grn_logger_set(937c97a7242c3be2).(grn_ctxcxx . . $ grn_ctx# *ctx, const grn_loggercxx . . $ grn_logger# *logger) |
| 525 | { |
| 526 | current_logger_fincxx . . $ current_logger_fin(b578cd6e53d5fe91).(ctx); |
| 527 | if (logger) { |
| 528 | current_loggercxx . . $ current_logger. = *logger; |
| 529 | } else { |
| 530 | current_loggercxx . . $ current_logger. = default_loggercxx . . $ default_logger.; |
| 531 | } |
| 532 | return GRN_SUCCESScxx . . $ GRN_SUCCESS.; |
| 533 | } |
| 534 | |
| 535 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! |
| 536 | grn_logger_is_default_loggercxx . . $ grn_logger_is_default_logger(6769dd2542d68818).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 537 | { |
| 538 | return current_loggercxx . . $ current_logger..logcxx . . $ _grn_logger#log. == default_loggercxx . . $ default_logger..logcxx . . $ _grn_logger#log.; |
| 539 | } |
| 540 | |
| 541 | void |
| 542 | grn_logger_set_max_levelcxx . . $ grn_logger_set_max_level(59adfd980b109eb9).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_log_levelcxx . . $ grn_log_level# max_level) |
| 543 | { |
| 544 | current_loggercxx . . $ current_logger..max_levelcxx . . $ _grn_logger#max_level. = max_level; |
| 545 | } |
| 546 | |
| 547 | grn_log_levelcxx . . $ grn_log_level# |
| 548 | grn_logger_get_max_levelcxx . . $ grn_logger_get_max_level(24044f8444e1c9ec).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 549 | { |
| 550 | return current_loggercxx . . $ current_logger..max_levelcxx . . $ _grn_logger#max_level.; |
| 551 | } |
| 552 | |
| 553 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! |
| 554 | grn_logger_passcxx . . $ grn_logger_pass(188766080ec9c0f2).(grn_ctxcxx . . $ grn_ctx# *ctx, grn_log_levelcxx . . $ grn_log_level# level) |
| 555 | { |
| 556 | return level <= current_loggercxx . . $ current_logger..max_levelcxx . . $ _grn_logger#max_level.; |
| 557 | } |
| 558 | |
| 559 | #define TBUFSIZEcxx . . $ `lib/logger.c:559:9`! GRN_TIMEVAL_STR_SIZEcxx . . $ `lib/grn_time.h:28:9`! |
| 560 | #define MBUFSIZEcxx . . $ `lib/logger.c:560:9`! 0x1000 |
| 561 | #define LBUFSIZEcxx . . $ `lib/logger.c:561:9`! 0x400 |
| 562 | |
| 563 | void |
| 564 | grn_logger_putcxx . . $ grn_logger_put(d93ace076242abaa).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 565 | grn_log_levelcxx . . $ grn_log_level# level, |
| 566 | const char *file, |
| 567 | int line, |
| 568 | const char *func, |
| 569 | const char *fmt, |
| 570 | ...) |
| 571 | { |
| 572 | va_listcxx . . $ va_list# ap; |
| 573 | va_startcxx . . $ `<external>/8293021631987149590/stdarg.h:51:9`!(ap, fmt); |
| 574 | grn_logger_putvcxx . . $ grn_logger_putv(76508e69ff1adf9d).(ctx, level, file, line, func, fmt, ap); |
| 575 | va_endcxx . . $ `<external>/8293021631987149590/stdarg.h:53:9`!(ap); |
| 576 | } |
| 577 | |
| 578 | void |
| 579 | grn_logger_putvcxx . . $ grn_logger_putv(76508e69ff1adf9d).(grn_ctxcxx . . $ grn_ctx# *ctx, |
| 580 | grn_log_levelcxx . . $ grn_log_level# level, |
| 581 | const char *file, |
| 582 | int line, |
| 583 | const char *func, |
| 584 | const char *fmt, |
| 585 | va_listcxx . . $ va_list# ap) |
| 586 | { |
| 587 | if (!ctx) { |
| 588 | ctx = &grn_gctxcxx . . $ grn_gctx.; |
| 589 | } |
| 590 | |
| 591 | if (level <= current_loggercxx . . $ current_logger..max_levelcxx . . $ _grn_logger#max_level. && current_loggercxx . . $ current_logger..logcxx . . $ _grn_logger#log.) { |
| 592 | char tbuf[TBUFSIZEcxx . . $ `lib/logger.c:559:9`!]; |
| 593 | char mbuf[MBUFSIZEcxx . . $ `lib/logger.c:560:9`!]; |
| 594 | char lbuf[LBUFSIZEcxx . . $ `lib/logger.c:561:9`!]; |
| 595 | tbuf[0] = '\0'; |
| 596 | if (current_loggercxx . . $ current_logger..flagscxx . . $ _grn_logger#flags. & GRN_LOG_TIMEcxx . . $ `include/groonga/groonga.h:2363:9`!) { |
| 597 | grn_timevalcxx . . $ grn_timeval# tv; |
| 598 | grn_timeval_nowcxx . . $ grn_timeval_now(b116eeadcb699bd1).(ctx, &tv); |
| 599 | grn_timeval2strcxx . . $ grn_timeval2str(52f9bd5a37f66b1d).(ctx, &tv, tbuf, TBUFSIZEcxx . . $ `lib/logger.c:559:9`!); |
| 600 | } |
| 601 | if (current_loggercxx . . $ current_logger..flagscxx . . $ _grn_logger#flags. & GRN_LOG_MESSAGEcxx . . $ `include/groonga/groonga.h:2365:9`!) { |
| 602 | grn_vsnprintfcxx . . $ `include/groonga/portability.h:148:11`!(mbuf, MBUFSIZEcxx . . $ `lib/logger.c:560:9`!, fmt, ap); |
| 603 | } else { |
| 604 | mbuf[0] = '\0'; |
| 605 | } |
| 606 | { |
| 607 | char *lbuf_current = lbuf; |
| 608 | size_t lbuf_rest_size = LBUFSIZEcxx . . $ `lib/logger.c:561:9`!; |
| 609 | lbuf[0] = '\0'; |
| 610 | lbuf_current = lbuf; |
| 611 | if ((current_loggercxx . . $ current_logger..flagscxx . . $ _grn_logger#flags. & GRN_LOG_PIDcxx . . $ `include/groonga/groonga.h:2367:9`!) || |
| 612 | /* For backward compatibility. GRN_LOG_LOCATION implies GRN_LOG_PID. */ |
| 613 | (current_loggercxx . . $ current_logger..flagscxx . . $ _grn_logger#flags. & GRN_LOG_LOCATIONcxx . . $ `include/groonga/groonga.h:2366:9`!)) { |
| 614 | grn_snprintfcxx . . $ `include/groonga/portability.h:137:11`!(lbuf_current, lbuf_rest_size, lbuf_rest_size, |
| 615 | "%d", grn_getpidcxx . . $ `include/groonga/portability.h:199:11`!()); |
| 616 | const size_t lbuf_size = strlencxx . . $ strlen(751346f8406fd082).(lbuf_current); |
| 617 | lbuf_current += lbuf_size; |
| 618 | lbuf_rest_size -= lbuf_size; |
| 619 | } |
| 620 | if (current_loggercxx . . $ current_logger..flagscxx . . $ _grn_logger#flags. & GRN_LOG_THREAD_IDcxx . . $ `include/groonga/groonga.h:2369:9`!) { |
| 621 | const char *prefix = ""; |
| 622 | if (lbuf_current != lbuf) { |
| 623 | prefix = "|"; |
| 624 | } |
| 625 | #ifdef HAVE_PTHREAD_Hcxx . . $ `build/config.h:133:9`! |
| 626 | grn_snprintfcxx . . $ `include/groonga/portability.h:137:11`!(lbuf_current, lbuf_rest_size, lbuf_rest_size, |
| 627 | "%s%08lx", prefix, (uintptr_t)(pthread_self())); |
| 628 | #elif defined(WIN32) /* HAVE_PTHREAD_H */ |
| 629 | grn_snprintf(lbuf_current, lbuf_rest_size, lbuf_rest_size, |
| 630 | "%s%08ld", prefix, GetCurrentThreadId()); |
| 631 | #endif /* HAVE_PTHREAD_H */ |
| 632 | const size_t lbuf_size = strlencxx . . $ strlen(751346f8406fd082).(lbuf_current); |
| 633 | lbuf_current += lbuf_size; |
| 634 | lbuf_rest_size -= lbuf_size; |
| 635 | } |
| 636 | if (current_loggercxx . . $ current_logger..flagscxx . . $ _grn_logger#flags. & GRN_LOG_CONTEXT_IDcxx . . $ `include/groonga/groonga.h:2370:9`!) { |
| 637 | const char *prefix = ""; |
| 638 | if (lbuf_current != lbuf) { |
| 639 | prefix = "|"; |
| 640 | } |
| 641 | grn_snprintfcxx . . $ `include/groonga/portability.h:137:11`!(lbuf_current, lbuf_rest_size, lbuf_rest_size, |
| 642 | "%s%p", prefix, ctx); |
| 643 | const size_t lbuf_size = strlencxx . . $ strlen(751346f8406fd082).(lbuf_current); |
| 644 | lbuf_current += lbuf_size; |
| 645 | lbuf_rest_size -= lbuf_size; |
| 646 | } |
| 647 | if (current_loggercxx . . $ current_logger..flagscxx . . $ _grn_logger#flags. & GRN_LOG_LOCATIONcxx . . $ `include/groonga/groonga.h:2366:9`!) { |
| 648 | const char *prefix = ""; |
| 649 | if (lbuf_current != lbuf) { |
| 650 | prefix = " "; |
| 651 | } |
| 652 | grn_snprintfcxx . . $ `include/groonga/portability.h:137:11`!(lbuf_current, lbuf_rest_size, lbuf_rest_size, |
| 653 | "%s%s:%d %s()", prefix, file, line, func); |
| 654 | const size_t lbuf_size = strlencxx . . $ strlen(751346f8406fd082).(lbuf_current); |
| 655 | lbuf_current += lbuf_size; |
| 656 | lbuf_rest_size -= lbuf_size; |
| 657 | } |
| 658 | } |
| 659 | |
| 660 | if (mbuf[0] == '\0') { |
| 661 | current_loggercxx . . $ current_logger..logcxx . . $ _grn_logger#log.(ctx, level, tbuf, "", mbuf, lbuf, |
| 662 | current_loggercxx . . $ current_logger..user_datacxx . . $ _grn_logger#user_data.); |
| 663 | } else { |
| 664 | const char *mbuf_line_start = mbuf; |
| 665 | const char *mbuf_end = mbuf + strlencxx . . $ strlen(751346f8406fd082).(mbuf); |
| 666 | int mbuf_char_length = 0; |
| 667 | for (char *mbuf_current = mbuf; |
| 668 | mbuf_current < mbuf_end; |
| 669 | mbuf_current += mbuf_char_length) { |
| 670 | mbuf_char_length = grn_charlencxx . . $ grn_charlen(d229e8bf7c87f0f0).(ctx, mbuf_current, mbuf_end); |
| 671 | if (mbuf_char_length == 0) { |
| 672 | break; |
| 673 | } else if (mbuf_char_length == 1 && mbuf_current[0] == '\n') { |
| 674 | mbuf_current[0] = '\0'; |
| 675 | current_loggercxx . . $ current_logger..logcxx . . $ _grn_logger#log.(ctx, level, tbuf, "", mbuf_line_start, lbuf, |
| 676 | current_loggercxx . . $ current_logger..user_datacxx . . $ _grn_logger#user_data.); |
| 677 | mbuf_line_start = mbuf_current + 1; |
| 678 | } |
| 679 | } |
| 680 | if (mbuf_line_start < mbuf_end) { |
| 681 | current_loggercxx . . $ current_logger..logcxx . . $ _grn_logger#log.(ctx, level, tbuf, "", mbuf_line_start, lbuf, |
| 682 | current_loggercxx . . $ current_logger..user_datacxx . . $ _grn_logger#user_data.); |
| 683 | } |
| 684 | } |
| 685 | } |
| 686 | } |
| 687 | |
| 688 | void |
| 689 | grn_logger_initcxx . . $ grn_logger_init(49f6e7a06ebc5aa8).(void) |
| 690 | { |
| 691 | grn_logger_output_initcxx . . $ grn_logger_output_init(a726f2281954d2f4).(&default_logger_outputcxx . . $ default_logger_output.); |
| 692 | if (!current_loggercxx . . $ current_logger..logcxx . . $ _grn_logger#log.) { |
| 693 | current_loggercxx . . $ current_logger. = default_loggercxx . . $ default_logger.; |
| 694 | } |
| 695 | |
| 696 | logger_initedcxx . . $ logger_inited. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 697 | } |
| 698 | |
| 699 | void |
| 700 | grn_logger_fincxx . . $ grn_logger_fin(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 701 | { |
| 702 | current_logger_fincxx . . $ current_logger_fin(b578cd6e53d5fe91).(ctx); |
| 703 | grn_logger_output_fincxx . . $ grn_logger_output_fin(1d8c945b22d5ac23).(ctx, &default_logger_outputcxx . . $ default_logger_output.); |
| 704 | logger_initedcxx . . $ logger_inited. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 705 | } |
| 706 | |
| 707 | |
| 708 | static boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! query_logger_initedcxx . . $ query_logger_inited. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 709 | static grn_logger_outputcxx . . $ grn_logger_output# default_query_logger_outputcxx . . $ default_query_logger_output. = {0}; |
| 710 | |
| 711 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! |
| 712 | grn_query_log_flags_parsecxx . . $ grn_query_log_flags_parse(78ed585585023718).(const char *string, |
| 713 | int string_size, |
| 714 | unsigned int *flags) |
| 715 | { |
| 716 | const char *string_end; |
| 717 | |
| 718 | *flags = GRN_QUERY_LOG_NONEcxx . . $ `include/groonga/groonga.h:211:9`!; |
| 719 | |
| 720 | if (!string) { |
| 721 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 722 | } |
| 723 | |
| 724 | if (string_size < 0) { |
| 725 | string_size = (int)strlencxx . . $ strlen(751346f8406fd082).(string); |
| 726 | } |
| 727 | |
| 728 | string_end = string + string_size; |
| 729 | |
| 730 | while (string < string_end) { |
| 731 | if (*string == '|' || *string == ' ') { |
| 732 | string += 1; |
| 733 | continue; |
| 734 | } |
| 735 | |
| 736 | #define CHECK_FLAGcxx . . $ `lib/logger.c:736:9`!(name) \ |
| 737 | if (((size_t)(string_end - string) >= (sizeof(#name) - 1)) && \ |
| 738 | (memcmp(string, #name, sizeof(#name) - 1) == 0) && \ |
| 739 | (((size_t)(string_end - string) == (sizeof(#name) - 1)) || \ |
| 740 | (string[sizeof(#name) - 1] == '|') || \ |
| 741 | (string[sizeof(#name) - 1] == ' '))) { \ |
| 742 | *flags |= GRN_QUERY_LOG_ ## name; \ |
| 743 | string += sizeof(#name) - 1; \ |
| 744 | continue; \ |
| 745 | } |
| 746 | |
| 747 | CHECK_FLAGcxx . . $ `lib/logger.c:736:9`!(NONE); |
| 748 | CHECK_FLAGcxx . . $ `lib/logger.c:736:9`!(COMMAND); |
| 749 | CHECK_FLAGcxx . . $ `lib/logger.c:736:9`!(RESULT_CODE); |
| 750 | CHECK_FLAGcxx . . $ `lib/logger.c:736:9`!(DESTINATION); |
| 751 | CHECK_FLAGcxx . . $ `lib/logger.c:736:9`!(CACHE); |
| 752 | CHECK_FLAGcxx . . $ `lib/logger.c:736:9`!(SIZE); |
| 753 | CHECK_FLAGcxx . . $ `lib/logger.c:736:9`!(SCORE); |
| 754 | CHECK_FLAGcxx . . $ `lib/logger.c:736:9`!(ALL); |
| 755 | CHECK_FLAGcxx . . $ `lib/logger.c:736:9`!(DEFAULT); |
| 756 | |
| 757 | #undef CHECK_FLAGcxx . . $ `lib/logger.c:736:9`! |
| 758 | |
| 759 | return falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 760 | } |
| 761 | |
| 762 | return truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 763 | } |
| 764 | |
| 765 | static void |
| 766 | default_query_logger_logcxx . . $ default_query_logger_log(3b670c8c52f923f).(grn_ctxcxx . . $ grn_ctx# *ctx, unsigned int flag, |
| 767 | const char *timestamp, const char *info, |
| 768 | const char *message, void *user_data) |
| 769 | { |
| 770 | if (!grn_logger_output_startcxx . . $ grn_logger_output_start(6ecbd6d13493afa7).(ctx, |
| 771 | &default_query_logger_outputcxx . . $ default_query_logger_output., |
| 772 | (current_loggercxx . . $ current_logger..flagscxx . . $ _grn_logger#flags. & GRN_LOG_PIDcxx . . $ `include/groonga/groonga.h:2367:9`!))) { |
| 773 | return; |
| 774 | } |
| 775 | int written = fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(default_query_logger_outputcxx . . $ default_query_logger_output..filecxx . . $ $anonymous_type_99e57209684e9df1_1#file., "%s|%s%s\n", |
| 776 | timestamp, info, message); |
| 777 | grn_logger_output_endcxx . . $ grn_logger_output_end(56c9afbf588437a).(ctx, &default_query_logger_outputcxx . . $ default_query_logger_output., written); |
| 778 | } |
| 779 | |
| 780 | static void |
| 781 | default_query_logger_closecxx . . $ default_query_logger_close(b6b6153f622d9caa).(grn_ctxcxx . . $ grn_ctx# *ctx, void *user_data) |
| 782 | { |
| 783 | GRN_QUERY_LOGcxx . . $ `include/groonga/groonga.h:2585:9`!(ctx, GRN_QUERY_LOG_DESTINATIONcxx . . $ `include/groonga/groonga.h:214:9`!, " ", |
| 784 | "query log will be closed: <%s>", |
| 785 | default_query_logger_output.path); |
| 786 | grn_logger_output_closecxx . . $ grn_logger_output_close(1d8c945b22d5ac23).(ctx, &default_query_logger_outputcxx . . $ default_query_logger_output.); |
| 787 | } |
| 788 | |
| 789 | static void |
| 790 | default_query_logger_reopencxx . . $ default_query_logger_reopen(b6b6153f622d9caa).(grn_ctxcxx . . $ grn_ctx# *ctx, void *user_data) |
| 791 | { |
| 792 | default_query_logger_closecxx . . $ default_query_logger_close(b6b6153f622d9caa).(ctx, user_data); |
| 793 | if (default_query_logger_outputcxx . . $ default_query_logger_output..pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path.) { |
| 794 | GRN_QUERY_LOGcxx . . $ `include/groonga/groonga.h:2585:9`!(ctx, GRN_QUERY_LOG_DESTINATIONcxx . . $ `include/groonga/groonga.h:214:9`!, " ", |
| 795 | "query log is opened: <%s>", |
| 796 | default_query_logger_output.path); |
| 797 | } |
| 798 | } |
| 799 | |
| 800 | static void |
| 801 | default_query_logger_fincxx . . $ default_query_logger_fin(b6b6153f622d9caa).(grn_ctxcxx . . $ grn_ctx# *ctx, void *user_data) |
| 802 | { |
| 803 | default_query_logger_closecxx . . $ default_query_logger_close(b6b6153f622d9caa).(ctx, user_data); |
| 804 | } |
| 805 | |
| 806 | static grn_query_loggercxx . . $ grn_query_logger# default_query_loggercxx . . $ default_query_logger. = { |
| 807 | GRN_QUERY_LOG_DEFAULTcxx . . $ `include/groonga/groonga.h:222:9`!, |
| 808 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, |
| 809 | default_query_logger_logcxx . . $ default_query_logger_log(3b670c8c52f923f)., |
| 810 | default_query_logger_reopencxx . . $ default_query_logger_reopen(b6b6153f622d9caa)., |
| 811 | default_query_logger_fincxx . . $ default_query_logger_fin(b6b6153f622d9caa). |
| 812 | }; |
| 813 | |
| 814 | #define INITIAL_QUERY_LOGGERcxx . . $ `lib/logger.c:814:9`! { \ |
| 815 | GRN_QUERY_LOG_DEFAULTcxx . . $ `include/groonga/groonga.h:222:9`!, \ |
| 816 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, \ |
| 817 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, \ |
| 818 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!, \ |
| 819 | NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`! \ |
| 820 | } |
| 821 | |
| 822 | static grn_query_loggercxx . . $ grn_query_logger# current_query_loggercxx . . $ current_query_logger. = INITIAL_QUERY_LOGGERcxx . . $ `lib/logger.c:814:9`!; |
| 823 | |
| 824 | void |
| 825 | grn_default_query_logger_set_flagscxx . . $ grn_default_query_logger_set_flags(cb2f890c2fdad230).(unsigned int flags) |
| 826 | { |
| 827 | default_query_loggercxx . . $ default_query_logger..flagscxx . . $ _grn_query_logger#flags. = flags; |
| 828 | if (current_query_loggercxx . . $ current_query_logger..logcxx . . $ _grn_query_logger#log. == default_query_logger_logcxx . . $ default_query_logger_log(3b670c8c52f923f).) { |
| 829 | current_query_loggercxx . . $ current_query_logger..flagscxx . . $ _grn_query_logger#flags. = flags; |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | unsigned int |
| 834 | grn_default_query_logger_get_flagscxx . . $ grn_default_query_logger_get_flags(db52760e79bf9054).(void) |
| 835 | { |
| 836 | return default_query_loggercxx . . $ default_query_logger..flagscxx . . $ _grn_query_logger#flags.; |
| 837 | } |
| 838 | |
| 839 | void |
| 840 | grn_default_query_logger_set_pathcxx . . $ grn_default_query_logger_set_path(85c52e162fed56f9).(const char *path) |
| 841 | { |
| 842 | if (query_logger_initedcxx . . $ query_logger_inited.) { |
| 843 | CRITICAL_SECTION_ENTERcxx . . $ `lib/grn.h:227:11`!(default_query_logger_output.lock); |
| 844 | } |
| 845 | |
| 846 | if (default_query_logger_outputcxx . . $ default_query_logger_output..pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path.) { |
| 847 | freecxx . . $ free(5d22bdacc48458e8).(default_query_logger_outputcxx . . $ default_query_logger_output..pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path.); |
| 848 | } |
| 849 | |
| 850 | if (path) { |
| 851 | default_query_logger_outputcxx . . $ default_query_logger_output..pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path. = grn_strdup_rawcxx . . $ `include/groonga/portability.h:82:11`!(path); |
| 852 | } else { |
| 853 | default_query_logger_outputcxx . . $ default_query_logger_output..pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/16/include/stddef.h:419:9`!; |
| 854 | } |
| 855 | |
| 856 | if (query_logger_initedcxx . . $ query_logger_inited.) { |
| 857 | CRITICAL_SECTION_LEAVEcxx . . $ `lib/grn.h:228:11`!(default_query_logger_output.lock); |
| 858 | } |
| 859 | } |
| 860 | |
| 861 | const char * |
| 862 | grn_default_query_logger_get_pathcxx . . $ grn_default_query_logger_get_path(33a1f659e94feb42).(void) |
| 863 | { |
| 864 | return default_query_logger_outputcxx . . $ default_query_logger_output..pathcxx . . $ $anonymous_type_99e57209684e9df1_1#path.; |
| 865 | } |
| 866 | |
| 867 | void |
| 868 | grn_default_query_logger_set_rotate_threshold_sizecxx . . $ grn_default_query_logger_set_rotate_threshold_size(1624ee8275b10bda).(off_tcxx . . $ off_t# threshold) |
| 869 | { |
| 870 | default_query_logger_outputcxx . . $ default_query_logger_output..rotate_threshold_sizecxx . . $ $anonymous_type_99e57209684e9df1_1#rotate_threshold_size. = threshold; |
| 871 | } |
| 872 | |
| 873 | off_tcxx . . $ off_t# |
| 874 | grn_default_query_logger_get_rotate_threshold_sizecxx . . $ grn_default_query_logger_get_rotate_threshold_size(da6335ded91d79c2).(void) |
| 875 | { |
| 876 | return default_query_logger_outputcxx . . $ default_query_logger_output..rotate_threshold_sizecxx . . $ $anonymous_type_99e57209684e9df1_1#rotate_threshold_size.; |
| 877 | } |
| 878 | |
| 879 | void |
| 880 | grn_query_logger_reopencxx . . $ grn_query_logger_reopen(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 881 | { |
| 882 | if (current_query_loggercxx . . $ current_query_logger..reopencxx . . $ _grn_query_logger#reopen.) { |
| 883 | current_query_loggercxx . . $ current_query_logger..reopencxx . . $ _grn_query_logger#reopen.(ctx, current_query_loggercxx . . $ current_query_logger..user_datacxx . . $ _grn_query_logger#user_data.); |
| 884 | } |
| 885 | } |
| 886 | |
| 887 | static void |
| 888 | current_query_logger_fincxx . . $ current_query_logger_fin(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 889 | { |
| 890 | if (current_query_loggercxx . . $ current_query_logger..fincxx . . $ _grn_query_logger#fin.) { |
| 891 | current_query_loggercxx . . $ current_query_logger..fincxx . . $ _grn_query_logger#fin.(ctx, current_query_loggercxx . . $ current_query_logger..user_datacxx . . $ _grn_query_logger#user_data.); |
| 892 | } |
| 893 | { |
| 894 | grn_query_loggercxx . . $ grn_query_logger# initial_query_logger = INITIAL_QUERY_LOGGERcxx . . $ `lib/logger.c:814:9`!; |
| 895 | current_query_loggercxx . . $ current_query_logger. = initial_query_logger; |
| 896 | } |
| 897 | } |
| 898 | |
| 899 | grn_rccxx . . $ grn_rc# |
| 900 | grn_query_logger_setcxx . . $ grn_query_logger_set(af9cca702b232aeb).(grn_ctxcxx . . $ grn_ctx# *ctx, const grn_query_loggercxx . . $ grn_query_logger# *logger) |
| 901 | { |
| 902 | current_query_logger_fincxx . . $ current_query_logger_fin(b578cd6e53d5fe91).(ctx); |
| 903 | if (logger) { |
| 904 | current_query_loggercxx . . $ current_query_logger. = *logger; |
| 905 | } else { |
| 906 | current_query_loggercxx . . $ current_query_logger. = default_query_loggercxx . . $ default_query_logger.; |
| 907 | } |
| 908 | return GRN_SUCCESScxx . . $ GRN_SUCCESS.; |
| 909 | } |
| 910 | |
| 911 | void |
| 912 | grn_query_logger_set_flagscxx . . $ grn_query_logger_set_flags(969b9cdb234920c4).(grn_ctxcxx . . $ grn_ctx# *ctx, unsigned int flags) |
| 913 | { |
| 914 | current_query_loggercxx . . $ current_query_logger..flagscxx . . $ _grn_query_logger#flags. = flags; |
| 915 | } |
| 916 | |
| 917 | void |
| 918 | grn_query_logger_add_flagscxx . . $ grn_query_logger_add_flags(969b9cdb234920c4).(grn_ctxcxx . . $ grn_ctx# *ctx, unsigned int flags) |
| 919 | { |
| 920 | current_query_loggercxx . . $ current_query_logger..flagscxx . . $ _grn_query_logger#flags. |= flags; |
| 921 | } |
| 922 | |
| 923 | void |
| 924 | grn_query_logger_remove_flagscxx . . $ grn_query_logger_remove_flags(969b9cdb234920c4).(grn_ctxcxx . . $ grn_ctx# *ctx, unsigned int flags) |
| 925 | { |
| 926 | current_query_loggercxx . . $ current_query_logger..flagscxx . . $ _grn_query_logger#flags. &= ~flags; |
| 927 | } |
| 928 | |
| 929 | unsigned int |
| 930 | grn_query_logger_get_flagscxx . . $ grn_query_logger_get_flags(42892115b099e3b9).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 931 | { |
| 932 | return current_query_loggercxx . . $ current_query_logger..flagscxx . . $ _grn_query_logger#flags.; |
| 933 | } |
| 934 | |
| 935 | boolcxx . . $ `<external>/13015445228558014418/stdbool.h:36:9`! |
| 936 | grn_query_logger_passcxx . . $ grn_query_logger_pass(a2a496425acc5b40).(grn_ctxcxx . . $ grn_ctx# *ctx, unsigned int flag) |
| 937 | { |
| 938 | return current_query_loggercxx . . $ current_query_logger..flagscxx . . $ _grn_query_logger#flags. & flag; |
| 939 | } |
| 940 | |
| 941 | #define TIMESTAMP_BUFFER_SIZEcxx . . $ `lib/logger.c:941:9`! TBUFSIZEcxx . . $ `lib/logger.c:559:9`! |
| 942 | /* 8+a(%p) + 1(|) + 1(mark) + 15(elapsed time) = 25+a */ |
| 943 | #define INFO_BUFFER_SIZEcxx . . $ `lib/logger.c:943:9`! 40 |
| 944 | |
| 945 | void |
| 946 | grn_query_logger_putcxx . . $ grn_query_logger_put(7b375168e1a7db49).(grn_ctxcxx . . $ grn_ctx# *ctx, unsigned int flag, const char *mark, |
| 947 | const char *format, ...) |
| 948 | { |
| 949 | char timestamp[TIMESTAMP_BUFFER_SIZEcxx . . $ `lib/logger.c:941:9`!]; |
| 950 | char info[INFO_BUFFER_SIZEcxx . . $ `lib/logger.c:943:9`!]; |
| 951 | grn_objcxx . . $ grn_obj# *message = &ctx->implcxx . . $ _grn_ctx#impl.->query_log_bufcxx . . $ _grn_ctx_impl#query_log_buf.; |
| 952 | |
| 953 | if (!current_query_loggercxx . . $ current_query_logger..logcxx . . $ _grn_query_logger#log.) { |
| 954 | return; |
| 955 | } |
| 956 | |
| 957 | { |
| 958 | grn_timevalcxx . . $ grn_timeval# tv; |
| 959 | timestamp[0] = '\0'; |
| 960 | grn_timeval_nowcxx . . $ grn_timeval_now(b116eeadcb699bd1).(ctx, &tv); |
| 961 | grn_timeval2strcxx . . $ grn_timeval2str(52f9bd5a37f66b1d).(ctx, &tv, timestamp, TIMESTAMP_BUFFER_SIZEcxx . . $ `lib/logger.c:941:9`!); |
| 962 | } |
| 963 | |
| 964 | grn_ctxcxx . . $ grn_ctx# *target_ctx = ctx; |
| 965 | while (target_ctx->implcxx . . $ _grn_ctx#impl.->parentcxx . . $ _grn_ctx_impl#parent.) { |
| 966 | target_ctx = target_ctx->implcxx . . $ _grn_ctx#impl.->parentcxx . . $ _grn_ctx_impl#parent.; |
| 967 | } |
| 968 | if (flag & (GRN_QUERY_LOG_COMMANDcxx . . $ `include/groonga/groonga.h:212:9`! | GRN_QUERY_LOG_DESTINATIONcxx . . $ `include/groonga/groonga.h:214:9`!)) { |
| 969 | grn_snprintfcxx . . $ `include/groonga/portability.h:137:11`!(info, INFO_BUFFER_SIZE, INFO_BUFFER_SIZEcxx . . $ `lib/logger.c:943:9`!, |
| 970 | "%p|%s", target_ctx, mark); |
| 971 | info[INFO_BUFFER_SIZEcxx . . $ `lib/logger.c:943:9`! - 1] = '\0'; |
| 972 | } else { |
| 973 | grn_timevalcxx . . $ grn_timeval# tv; |
| 974 | uint64_tcxx . . $ uint64_t# elapsed_time; |
| 975 | grn_timeval_nowcxx . . $ grn_timeval_now(b116eeadcb699bd1).(ctx, &tv); |
| 976 | elapsed_time = |
| 977 | (uint64_tcxx . . $ uint64_t#)(tv.tv_seccxx . . $ $anonymous_type_1555d7cc1d218aa4_15#tv_sec. - target_ctx->implcxx . . $ _grn_ctx#impl.->tvcxx . . $ _grn_ctx_impl#tv..tv_seccxx . . $ $anonymous_type_1555d7cc1d218aa4_15#tv_sec.) * |
| 978 | GRN_TIME_NSEC_PER_SECcxx . . $ `include/groonga/time.h:35:9`! + |
| 979 | (uint64_tcxx . . $ uint64_t#)(tv.tv_nseccxx . . $ $anonymous_type_1555d7cc1d218aa4_15#tv_nsec. - target_ctx->implcxx . . $ _grn_ctx#impl.->tvcxx . . $ _grn_ctx_impl#tv..tv_nseccxx . . $ $anonymous_type_1555d7cc1d218aa4_15#tv_nsec.); |
| 980 | |
| 981 | grn_snprintfcxx . . $ `include/groonga/portability.h:137:11`!(info, INFO_BUFFER_SIZE, INFO_BUFFER_SIZEcxx . . $ `lib/logger.c:943:9`!, |
| 982 | "%p|%s%015" GRN_FMT_INT64Ucxx . . $ `lib/grn.h:370:11`! " ", target_ctx, mark, elapsed_time); |
| 983 | info[INFO_BUFFER_SIZEcxx . . $ `lib/logger.c:943:9`! - 1] = '\0'; |
| 984 | } |
| 985 | |
| 986 | { |
| 987 | va_listcxx . . $ va_list# args; |
| 988 | |
| 989 | va_startcxx . . $ `<external>/8293021631987149590/stdarg.h:51:9`!(args, format); |
| 990 | GRN_BULK_REWINDcxx . . $ `include/groonga/groonga.h:2599:9`!(message); |
| 991 | grn_text_printfvcxx . . $ grn_text_printfv(26ae3e66154406).(ctx, message, format, args); |
| 992 | va_endcxx . . $ `<external>/8293021631987149590/stdarg.h:53:9`!(args); |
| 993 | GRN_TEXT_PUTCcxx . . $ `include/groonga/groonga.h:2775:9`!(ctx, message, '\0'); |
| 994 | } |
| 995 | |
| 996 | current_query_loggercxx . . $ current_query_logger..logcxx . . $ _grn_query_logger#log.(ctx, flag, timestamp, info, GRN_TEXT_VALUEcxx . . $ `include/groonga/groonga.h:2785:9`!(message), |
| 997 | current_query_loggercxx . . $ current_query_logger..user_datacxx . . $ _grn_query_logger#user_data.); |
| 998 | } |
| 999 | |
| 1000 | void |
| 1001 | grn_query_logger_initcxx . . $ grn_query_logger_init(49f6e7a06ebc5aa8).(void) |
| 1002 | { |
| 1003 | current_query_loggercxx . . $ current_query_logger. = default_query_loggercxx . . $ default_query_logger.; |
| 1004 | grn_logger_output_initcxx . . $ grn_logger_output_init(a726f2281954d2f4).(&default_query_logger_outputcxx . . $ default_query_logger_output.); |
| 1005 | query_logger_initedcxx . . $ query_logger_inited. = truecxx . . $ `<external>/13015445228558014418/stdbool.h:37:9`!; |
| 1006 | } |
| 1007 | |
| 1008 | void |
| 1009 | grn_query_logger_fincxx . . $ grn_query_logger_fin(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 1010 | { |
| 1011 | current_query_logger_fincxx . . $ current_query_logger_fin(b578cd6e53d5fe91).(ctx); |
| 1012 | grn_logger_output_fincxx . . $ grn_logger_output_fin(1d8c945b22d5ac23).(ctx, &default_query_logger_outputcxx . . $ default_query_logger_output.); |
| 1013 | query_logger_initedcxx . . $ query_logger_inited. = falsecxx . . $ `<external>/13015445228558014418/stdbool.h:38:9`!; |
| 1014 | } |
| 1015 | |
| 1016 | void |
| 1017 | grn_log_reopencxx . . $ grn_log_reopen(b578cd6e53d5fe91).(grn_ctxcxx . . $ grn_ctx# *ctx) |
| 1018 | { |
| 1019 | grn_logger_reopencxx . . $ grn_logger_reopen(b578cd6e53d5fe91).(ctx); |
| 1020 | grn_query_logger_reopencxx . . $ grn_query_logger_reopen(b578cd6e53d5fe91).(ctx); |
| 1021 | } |