Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:39

0001 #pragma once
0002 /**
0003 slog.h
0004 ========
0005 
0006 See notes/issues/logging_from_headeronly_impls.rst
0007 
0008 
0009 **/
0010 
0011 #include <cstdlib>
0012 #include <cstring>
0013 #include <sstream>
0014 #include <iostream>
0015 
0016 #include "plog/Severity.h"
0017 #include <plog/Log.h>
0018 
0019 using plog::fatal ; 
0020 using plog::error ; 
0021 using plog::warning ; 
0022 using plog::info ; 
0023 using plog::debug ; 
0024 using plog::verbose ; 
0025 
0026 
0027 struct slog
0028 {
0029     static plog::Severity envlevel( const char* key, const char* fallback); 
0030     static std::string Desc(plog::Severity level) ; 
0031     static std::string Dump() ; 
0032 };
0033 
0034 inline plog::Severity slog::envlevel(const char* key, const char* fallback)
0035 {
0036     const char* val = getenv(key);
0037     const char* level = val ? val : fallback ; 
0038     plog::Severity severity = plog::severityFromString(level) ;
0039 
0040     if(strcmp(level, fallback) != 0)
0041     {
0042         std::cerr 
0043             << "slog::envlevel"
0044             << " adjusting loglevel by envvar  "
0045             << " key " << key  
0046             << " val " << val  
0047             << " fallback " << fallback
0048             << " level " << level
0049             << " severity " << severity 
0050             << std::endl 
0051             ;     
0052     }
0053     return severity ; 
0054 }
0055 
0056 inline std::string slog::Desc(plog::Severity level) // static
0057 {
0058     std::stringstream ss ; 
0059     ss << "slog::Desc"
0060        << " level:" << level 
0061        << " plog::severityToString(level):" << plog::severityToString(level) 
0062        << std::endl  
0063        ; 
0064     std::string str = ss.str(); 
0065     return str ; 
0066 }
0067 inline std::string slog::Dump() // static
0068 {
0069     std::stringstream ss ; 
0070     ss
0071         << " slog::dump " << std::endl
0072         << " plog::none    " << plog::none << std::endl 
0073         << " plog::fatal   " << plog::fatal << std::endl 
0074         << " plog::error   " << plog::error << std::endl   
0075         << " plog::warning " << plog::warning << std::endl 
0076         << " plog::info    " << plog::info << std::endl 
0077         << " plog::debug   " << plog::debug << std::endl 
0078         << " plog::verbose " << plog::verbose << std::endl   
0079         ; 
0080 
0081     std::string str = ss.str(); 
0082     return str ; 
0083 }
0084 
0085 
0086