Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-02 07:54:40

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