| 252 | } |
| 253 | |
| 254 | DiagsConfig::DiagsConfig(std::string_view prefix_string, const char *filename, const char *tags, const char *actions, |
| 255 | bool use_records) |
| 256 | : callbacks_established(false), diags_log(nullptr), _diags(nullptr) |
| 257 | { |
| 258 | ats_scoped_str logpath; |
| 259 | |
| 260 | //////////////////////////////////////////////////////////////////// |
| 261 | // If we aren't using the manager records for configuration // |
| 262 | // just build the tables based on command line parameters and // |
| 263 | // exit // |
| 264 | //////////////////////////////////////////////////////////////////// |
| 265 | |
| 266 | if (!use_records) { |
| 267 | _diags = new Diags(prefix_string, tags, actions, nullptr); |
| 268 | DiagsPtr::set(_diags); |
| 269 | config_diags_norecords(); |
| 270 | return; |
| 271 | } |
| 272 | |
| 273 | // Open the diagnostics log. If proxy.config.log.logfile_dir is set use that, otherwise fall |
| 274 | // back to the configured log directory. |
| 275 | |
| 276 | logpath = RecConfigReadLogDir(); |
| 277 | if (access(logpath, W_OK | R_OK) == -1) { |
| 278 | fprintf(stderr, "unable to access log directory '%s': %d, %s\n", (const char *)logpath, errno, strerror(errno)); |
| 279 | fprintf(stderr, "please set 'proxy.config.log.logfile_dir'\n"); |
| 280 | ::exit(1); |
| 281 | } |
| 282 | |
| 283 | std::string diags_logpath{filename}; |
| 284 | // "stdout" and "stderr" are treated specially by BaseLogFile and are used to |
| 285 | // write to the stdout and stderr streams, respectively. If the caller |
| 286 | // specified these, we don't prepend any path and simply pass those strings |
| 287 | // as such to BaseLogFile. |
| 288 | if (diags_logpath != "stdout" && diags_logpath != "stderr") { |
| 289 | char buf[PATH_NAME_MAX]; |
| 290 | ink_filepath_make(buf, sizeof(buf), logpath, filename); |
| 291 | diags_logpath = std::string(buf); |
| 292 | } |
| 293 | |
| 294 | // Grab rolling intervals from configuration |
| 295 | // TODO error check these values |
| 296 | int output_log_roll_int = static_cast<int>(REC_ConfigReadInteger("proxy.config.output.logfile.rolling_interval_sec")); |
| 297 | int output_log_roll_size = static_cast<int>(REC_ConfigReadInteger("proxy.config.output.logfile.rolling_size_mb")); |
| 298 | int output_log_roll_enable = static_cast<int>(REC_ConfigReadInteger("proxy.config.output.logfile.rolling_enabled")); |
| 299 | int diags_log_roll_int = static_cast<int>(REC_ConfigReadInteger("proxy.config.diags.logfile.rolling_interval_sec")); |
| 300 | int diags_log_roll_size = static_cast<int>(REC_ConfigReadInteger("proxy.config.diags.logfile.rolling_size_mb")); |
| 301 | int diags_log_roll_enable = static_cast<int>(REC_ConfigReadInteger("proxy.config.diags.logfile.rolling_enabled")); |
| 302 | |
| 303 | // Grab some perms for the actual files on disk |
| 304 | char *diags_perm = REC_ConfigReadString("proxy.config.diags.logfile_perm"); |
| 305 | char *output_perm = REC_ConfigReadString("proxy.config.output.logfile_perm"); |
| 306 | int diags_perm_parsed = diags_perm ? ink_fileperm_parse(diags_perm) : -1; |
| 307 | int output_perm_parsed = diags_perm ? ink_fileperm_parse(output_perm) : -1; |
| 308 | |
| 309 | ats_free(diags_perm); |
| 310 | ats_free(output_perm); |
| 311 |
nothing calls this directly
no test coverage detected