Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*
0002  * Copyright (c) 2019 Opticks Team. All Rights Reserved.
0003  *
0004  * This file is part of Opticks
0005  * (see https://bitbucket.org/simoncblyth/opticks).
0006  *
0007  * Licensed under the Apache License, Version 2.0 (the "License"); 
0008  * you may not use this file except in compliance with the License.  
0009  * You may obtain a copy of the License at
0010  *
0011  *   http://www.apache.org/licenses/LICENSE-2.0
0012  *
0013  * Unless required by applicable law or agreed to in writing, software 
0014  * distributed under the License is distributed on an "AS IS" BASIS, 
0015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0016  * See the License for the specific language governing permissions and 
0017  * limitations under the License.
0018  */
0019 
0020 #pragma once
0021 
0022 /**
0023 SLOG.hh
0024 ==========
0025 
0026 See SLOG.rst for notes. 
0027 
0028 **/
0029 
0030 
0031 #include <cstddef>
0032 #include <string>
0033 #include <plog/Log.h>
0034 
0035 // NB DANGEROUS "USING" OF LOGLEVEL NAMES
0036 //    INCLUDE THIS AS THE LAST HEADER
0037 //    TO AVOID REPLACING STRINGS IN SYSTEM HEADERS
0038 //
0039 // plog log levels 
0040 using plog::none  ;    // 0
0041 using plog::fatal ;    // 1
0042 using plog::error ;    // 2
0043 using plog::warning ;  // 3 
0044 using plog::info ;     // 4
0045 using plog::debug ;    // 5
0046 using plog::verbose ;  // 6 
0047 
0048 #include "SYSRAP_API_EXPORT.hh"
0049 
0050 struct SLOG ; 
0051 
0052 #include <string>
0053 #include "SAr.hh"
0054 
0055 struct SYSRAP_API SLOG 
0056 {
0057     static const int MAXARGC ; 
0058 
0059     SAr         args ; 
0060 
0061     int         level ; 
0062     const char* filename ; 
0063     int         maxFileSize ;    // bytes
0064     int         maxFiles ; 
0065 
0066 
0067     template<int IDX>
0068     static plog::Severity MaxSeverity(plog::Logger<IDX>* logger) ; 
0069 
0070     template<int IDX>
0071     static const char* MaxSeverityString(plog::Logger<IDX>* logger) ; 
0072 
0073     template<int IDX>
0074     static std::string Desc(plog::Logger<IDX>* logger); 
0075 
0076     template<int IDX>
0077     static std::string Desc(); 
0078 
0079 
0080     static std::string Banner(); 
0081     std::string banner() const ; 
0082 
0083 
0084     static void Dump(); 
0085     static std::string Flags(); 
0086 
0087 
0088     static plog::Severity Delta(plog::Severity level_, int delta); 
0089     static plog::Severity EnvLevel( const char* key, const char* fallback); 
0090 
0091     SLOG(const char* name, const char* fallback="VERBOSE", const char* prefix=NULL );
0092     SLOG(int argc, char** argv, const char* fallback="VERBOSE", const char* prefix=NULL );
0093     void init(const char* fallback, const char* prefix); 
0094     std::string desc() const ; 
0095 
0096     const char* name(); 
0097     const char* exename() const ;
0098     const char* cmdline() const ;
0099     const char* get_arg_after(const char* option, const char* fallback) const ;
0100     int         get_int_after(const char* option, const char* fallback) const ;
0101     bool        has_arg(const char* arg) const ; 
0102 
0103     int parse( const char* fallback);
0104     int parse( plog::Severity _fallback);
0105 
0106     int prefixlevel_parse( int fallback, const char* prefix);
0107     int prefixlevel_parse( const char* fallback, const char* prefix);
0108     int prefixlevel_parse( plog::Severity _fallback, const char* prefix);
0109 
0110     static int  _parse(int argc, char** argv, const char* fallback);
0111     static int  _prefixlevel_parse(int argc, char** argv, const char* fallback, const char* prefix);
0112     static void _dump(const char* msg, int argc, char** argv);
0113     static const char* _name(plog::Severity severity);
0114     static const char* _name(int level);
0115     static const char* _logpath_parse_problematic(int argc, char** argv);
0116     static const char* _logpath();
0117 
0118     static SLOG* instance ; 
0119 };
0120 
0121 
0122 #include "SLOG_INIT.hh"
0123 
0124 // newer plog has _ID  older does not 
0125 #ifdef PLOG_DEFAULT_INSTANCE_ID
0126 #define SLOG_DEFAULT_INSTANCE_ID PLOG_DEFAULT_INSTANCE_ID
0127 #else
0128 #define SLOG_DEFAULT_INSTANCE_ID PLOG_DEFAULT_INSTANCE
0129 #endif
0130 
0131 #define sLOG(severity, delta)     LOG_(SLOG_DEFAULT_INSTANCE_ID, SLOG::Delta(severity,delta))
0132