Line data Source code
1 : #include "source/extensions/tracers/datadog/logger.h" 2 : 3 : #include <sstream> 4 : 5 : #include "datadog/error.h" 6 : 7 : namespace Envoy { 8 : namespace Extensions { 9 : namespace Tracers { 10 : namespace Datadog { 11 : 12 0 : Logger::Logger(spdlog::logger& logger) : logger_(logger) {} 13 : 14 : // datadog::tracing::Logger 15 : 16 0 : void Logger::log_error(const LogFunc& write) { 17 0 : if (!ENVOY_LOG_COMP_LEVEL(logger_, error)) { 18 0 : return; 19 0 : } 20 : 21 0 : std::ostringstream stream; 22 0 : write(stream); 23 0 : ENVOY_LOG_TO_LOGGER(logger_, error, "{}", stream.str()); 24 0 : } 25 : 26 0 : void Logger::log_startup(const LogFunc& write) { 27 0 : if (!ENVOY_LOG_COMP_LEVEL(logger_, info)) { 28 0 : return; 29 0 : } 30 : 31 0 : std::ostringstream stream; 32 0 : write(stream); 33 0 : ENVOY_LOG_TO_LOGGER(logger_, info, "{}", stream.str()); 34 0 : } 35 : 36 0 : void Logger::log_error(const datadog::tracing::Error& error) { 37 0 : ENVOY_LOG_TO_LOGGER(logger_, error, "Datadog [error {}]: {}", int(error.code), error.message); 38 0 : } 39 : 40 0 : void Logger::log_error(datadog::tracing::StringView message) { 41 0 : ENVOY_LOG_TO_LOGGER(logger_, error, "{}", message); 42 0 : } 43 : 44 : } // namespace Datadog 45 : } // namespace Tracers 46 : } // namespace Extensions 47 : } // namespace Envoy