Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-09-27 07:03:08

0001 #pragma once
0002 
0003 
0004 #include <JANA/JApplication.h>
0005 #include <JANA/Services/JServiceLocator.h>
0006 #include <spdlog/common.h>
0007 #include <spdlog/logger.h>
0008 #include <memory>
0009 #include <mutex>
0010 #include <optional>
0011 #include <string>
0012 
0013 /**
0014  * The Service centralizes use of spdlog
0015  */
0016 class Log_service : public JService
0017 {
0018 public:
0019     using level = spdlog::level::level_enum;
0020 
0021 public:
0022     explicit Log_service(JApplication *app);
0023     ~Log_service();
0024 
0025     /** Get a named logger with optional level
0026      * When no level is specified, the service default is used **/
0027     virtual std::shared_ptr<spdlog::logger> logger(
0028         const std::string &name,
0029         const std::optional<level> default_level = std::nullopt);
0030 
0031     /** Gets the default level for all loggers
0032      * The log level is set from user parameters or is 'info'**/
0033     virtual level getDefaultLevel();
0034 
0035     /** Gets std::string version of the default log level **/
0036     virtual std::string getDefaultLevelStr();
0037 
0038 private:
0039 
0040     Log_service()=default;
0041 
0042     std::recursive_mutex m_lock;
0043     JApplication* m_application;
0044     std::string m_log_level_str;
0045     std::string m_log_format_str;
0046 };