| 6299 | /************************** Logging API ****************************/ |
| 6300 | |
| 6301 | TSReturnCode |
| 6302 | TSTextLogObjectCreate(const char *filename, int mode, TSTextLogObject *new_object) |
| 6303 | { |
| 6304 | sdk_assert(sdk_sanity_check_null_ptr((void *)filename) == TS_SUCCESS); |
| 6305 | sdk_assert(sdk_sanity_check_null_ptr((void *)new_object) == TS_SUCCESS); |
| 6306 | |
| 6307 | if (mode < 0 || mode >= TS_LOG_MODE_INVALID_FLAG) { |
| 6308 | *new_object = nullptr; |
| 6309 | return TS_ERROR; |
| 6310 | } |
| 6311 | |
| 6312 | TextLogObject *tlog = new TextLogObject( |
| 6313 | filename, Log::config->logfile_dir, static_cast<bool>(mode) & TS_LOG_MODE_ADD_TIMESTAMP, nullptr, Log::config->rolling_enabled, |
| 6314 | Log::config->preproc_threads, Log::config->rolling_interval_sec, Log::config->rolling_offset_hr, Log::config->rolling_size_mb, |
| 6315 | Log::config->rolling_max_count, Log::config->rolling_min_count, Log::config->rolling_allow_empty); |
| 6316 | if (tlog == nullptr) { |
| 6317 | *new_object = nullptr; |
| 6318 | return TS_ERROR; |
| 6319 | } |
| 6320 | |
| 6321 | int err = (mode & TS_LOG_MODE_DO_NOT_RENAME ? Log::config->log_object_manager.manage_api_object(tlog, 0) : |
| 6322 | Log::config->log_object_manager.manage_api_object(tlog)); |
| 6323 | if (err != LogObjectManager::NO_FILENAME_CONFLICTS) { |
| 6324 | delete tlog; |
| 6325 | *new_object = nullptr; |
| 6326 | return TS_ERROR; |
| 6327 | } |
| 6328 | |
| 6329 | *new_object = reinterpret_cast<TSTextLogObject>(tlog); |
| 6330 | return TS_SUCCESS; |
| 6331 | } |
| 6332 | |
| 6333 | TSReturnCode |
| 6334 | TSTextLogObjectWrite(TSTextLogObject the_object, const char *format, ...) |