From ebfba13e0a757c4d63862f03c3f77c93889525e7 Mon Sep 17 00:00:00 2001 From: Jesse Mapel <jmapel@usgs.gov> Date: Thu, 11 Feb 2021 10:52:16 -0700 Subject: [PATCH] Added std out and error logging --- include/usgscsm/UsgsAstroPlugin.h | 1 - src/UsgsAstroPlugin.cpp | 13 ++++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/usgscsm/UsgsAstroPlugin.h b/include/usgscsm/UsgsAstroPlugin.h index 0a7b2a1..19a2829 100644 --- a/include/usgscsm/UsgsAstroPlugin.h +++ b/include/usgscsm/UsgsAstroPlugin.h @@ -9,7 +9,6 @@ #include <Version.h> #include <nlohmann/json.hpp> -#include "spdlog/sinks/basic_file_sink.h" #include "spdlog/spdlog.h" class UsgsAstroPlugin : public csm::Plugin { diff --git a/src/UsgsAstroPlugin.cpp b/src/UsgsAstroPlugin.cpp index e8c3773..d5eaaed 100644 --- a/src/UsgsAstroPlugin.cpp +++ b/src/UsgsAstroPlugin.cpp @@ -16,6 +16,9 @@ #include <csm.h> #include <math.h> +#include "spdlog/sinks/basic_file_sink.h" +#include "spdlog/sinks/stdout_color_sinks.h" + #include <nlohmann/json.hpp> using json = nlohmann::json; @@ -49,7 +52,15 @@ UsgsAstroPlugin::UsgsAstroPlugin() { if (logFile != "") { std::shared_ptr<spdlog::logger> m_logger = spdlog::get("usgscsm_logger"); - if (!m_logger) { + if (logFile == "stdout") { + std::shared_ptr<spdlog::logger> m_logger = + spdlog::stdout_color_mt("usgscsm_logger"); + } + else if (logFile == "stderr") { + std::shared_ptr<spdlog::logger> m_logger = + spdlog::stderr_color_mt("usgscsm_logger"); + } + else if (!m_logger) { std::shared_ptr<spdlog::logger> m_logger = spdlog::basic_logger_mt("usgscsm_logger", logFile); } -- GitLab