Back to home page

EIC code displayed by LXR

 
 

    


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

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 
0024 OPTICKS_LOG
0025 ===============
0026 
0027 Umbrella logging header bringing in logging headers from all linked Opticks subprojects 
0028 allowing the logging of each subproject to be individually controlled.
0029 
0030 The header was generated by sysrap-genlog-hh Sat Mar 23 20:08:11 CST 2019
0031 
0032 To regenerate the sysrap/OPTICKS_LOG.hh header use commandline::
0033 
0034      sysrap-;sysrap-genlog
0035 
0036 
0037 How to change formatting of logging 
0038 -------------------------------------
0039 
0040 Change the format by changing FMT typedef in SLOG_INIT.hh
0041 
0042 CAUTION: this will necessitate a recompilation of just about everything, 
0043 so do not change this often 
0044 
0045 Impl Notes
0046 ------------
0047 
0048 Note that although the below looks at first glance like it is breaking package
0049 dependency rules, it is of course not doing so because this header is included
0050 into the main (or point-of-use library) and the pre-processor macros 
0051 ensure that only the active package tree of headers gets included.
0052 
0053 TODO: rearrange OPTICKS_LOG such that it can be used in an initializer list 
0054 
0055 What you need to do to get logging to work for a package
0056 ------------------------------------------------------------
0057 
0058 * must implement logging stuff in header as this code is required by plog to live in the main, not in a lib
0059 * to get logging to work need:
0060 
0061 0. package must implement the PKGNAME_LOG.hh based on others
0062 1. package CMakeLists.txt must define the OPTICKS_PKGNAME compile definition
0063 2. include the compile definition protected OPTICKS_PKGNAME header into OPTICKS_LOG.hh
0064 3. add initialize call to OPTICKS_LOG_::Initialize
0065 4. add check call to OPTICKS_LOG_::Check  
0066 
0067 **/
0068 
0069 
0070 
0071 #include <cstdio>
0072 
0073 #ifdef OPTICKS_SYSRAP
0074 #include "SYSRAP_LOG.hh"
0075 #endif
0076 #ifdef OPTICKS_U4
0077 #include "U4_LOG.hh"
0078 #endif
0079 #ifdef OPTICKS_U4TEST
0080 #include "U4TEST_LOG.hh"
0081 #endif
0082 #ifdef OPTICKS_BRAP
0083 #include "BRAP_LOG.hh"
0084 #endif
0085 
0086 #ifdef OPTICKS_NPY
0087 #include "NPY_LOG.hh"
0088 #endif
0089 #ifdef OPTICKS_YOG
0090 #include "YOG_LOG.hh"
0091 #endif
0092 #ifdef OPTICKS_OKCORE
0093 #include "OKCORE_LOG.hh"
0094 #endif
0095 #ifdef OPTICKS_GGEO
0096 #include "GGEO_LOG.hh"
0097 #endif
0098 
0099 #ifdef OPTICKS_ASIRAP
0100 #include "ASIRAP_LOG.hh"
0101 #endif
0102 #ifdef OPTICKS_MESHRAP
0103 #include "MESHRAP_LOG.hh"
0104 #endif
0105 #ifdef OPTICKS_OKGEO
0106 #include "OKGEO_LOG.hh"
0107 #endif
0108 #ifdef OPTICKS_CUDARAP
0109 #include "CUDARAP_LOG.hh"
0110 #endif
0111 #ifdef OPTICKS_THRAP
0112 #include "THRAP_LOG.hh"
0113 #endif
0114 #ifdef OPTICKS_OXRAP
0115 #include "OXRAP_LOG.hh"
0116 #endif
0117 #ifdef OPTICKS_OKOP
0118 #include "OKOP_LOG.hh"
0119 #endif
0120 #ifdef OPTICKS_OGLRAP
0121 #include "OGLRAP_LOG.hh"
0122 #endif
0123 #ifdef OPTICKS_OKGL
0124 #include "OKGL_LOG.hh"
0125 #endif
0126 #ifdef OPTICKS_OK
0127 #include "OK_LOG.hh"
0128 #endif
0129 #ifdef OPTICKS_X4
0130 #include "X4_LOG.hh"
0131 #endif
0132 #ifdef OPTICKS_CFG4
0133 #include "CFG4_LOG.hh"
0134 #endif
0135 #ifdef OPTICKS_OKG4
0136 #include "OKG4_LOG.hh"
0137 #endif
0138 #ifdef OPTICKS_G4OK
0139 #include "G4OK_LOG.hh"
0140 #endif
0141 
0142 #ifdef OPTICKS_CSG
0143 #include "CSG_LOG.hh"
0144 #endif
0145 #ifdef OPTICKS_CSG_GGEO
0146 #include "CSG_GGEO_LOG.hh"
0147 #endif
0148 #ifdef OPTICKS_GEOCHAIN
0149 #include "GEOCHAIN_LOG.hh"
0150 #endif
0151 #ifdef OPTICKS_QUDARAP
0152 #include "QUDARAP_LOG.hh"
0153 #endif
0154 #ifdef OPTICKS_CSGOPTIX
0155 #include "CSGOPTIX_LOG.hh"
0156 #endif
0157 #ifdef OPTICKS_GDXML
0158 #include "GDXML_LOG.hh"
0159 #endif
0160 #ifdef OPTICKS_G4CX
0161 #include "G4CX_LOG.hh"
0162 #endif
0163 
0164 /*
0165 #ifdef WITH_PMTSIM
0166 #include "J_PMTSIM_LOG.hh"
0167 #endif
0168 */
0169 
0170 
0171 
0172 #include "SYSRAP_API_EXPORT.hh"
0173 
0174 
0175 #include "SLOG.hh"
0176 
0177 class SYSRAP_API OPTICKS_LOG_ {
0178    public:
0179        // initialize all linked loggers and hookup the main logger
0180        static void Initialize(SLOG* instance, void* app1, void* /*app2*/ )
0181        {
0182            int max_level = instance->parse("info") ;  
0183            // note : can decrease verbosity from the max_level in the subproj, but not increase
0184 
0185 #ifdef OPTICKS_SYSRAP
0186     SYSRAP_LOG::Initialize(instance->prefixlevel_parse( max_level, "SYSRAP"), app1, NULL );
0187 #endif
0188 #ifdef OPTICKS_U4
0189     U4_LOG::Initialize(instance->prefixlevel_parse( max_level, "U4"), app1, NULL );
0190 #endif
0191 #ifdef OPTICKS_BRAP
0192     BRAP_LOG::Initialize(instance->prefixlevel_parse( max_level, "BRAP"), app1, NULL );
0193 #endif
0194 
0195 #ifdef OPTICKS_NPY
0196     NPY_LOG::Initialize(instance->prefixlevel_parse( max_level, "NPY"), app1, NULL );
0197 #endif
0198 #ifdef OPTICKS_YOG
0199     YOG_LOG::Initialize(instance->prefixlevel_parse( max_level, "YOG"), app1, NULL );
0200 #endif
0201 #ifdef OPTICKS_OKCORE
0202     OKCORE_LOG::Initialize(instance->prefixlevel_parse( max_level, "OKCORE"), app1, NULL );
0203 #endif
0204 #ifdef OPTICKS_GGEO
0205     GGEO_LOG::Initialize(instance->prefixlevel_parse( max_level, "GGEO"), app1, NULL );
0206 #endif
0207 
0208 #ifdef OPTICKS_ASIRAP
0209     ASIRAP_LOG::Initialize(instance->prefixlevel_parse( max_level, "ASIRAP"), app1, NULL );
0210 #endif
0211 #ifdef OPTICKS_MESHRAP
0212     MESHRAP_LOG::Initialize(instance->prefixlevel_parse( max_level, "MESHRAP"), app1, NULL );
0213 #endif
0214 #ifdef OPTICKS_OKGEO
0215     OKGEO_LOG::Initialize(instance->prefixlevel_parse( max_level, "OKGEO"), app1, NULL );
0216 #endif
0217 #ifdef OPTICKS_CUDARAP
0218     CUDARAP_LOG::Initialize(instance->prefixlevel_parse( max_level, "CUDARAP"), app1, NULL );
0219 #endif
0220 #ifdef OPTICKS_THRAP
0221     THRAP_LOG::Initialize(instance->prefixlevel_parse( max_level, "THRAP"), app1, NULL );
0222 #endif
0223 #ifdef OPTICKS_OXRAP
0224     OXRAP_LOG::Initialize(instance->prefixlevel_parse( max_level, "OXRAP"), app1, NULL );
0225 #endif
0226 #ifdef OPTICKS_OKOP
0227     OKOP_LOG::Initialize(instance->prefixlevel_parse( max_level, "OKOP"), app1, NULL );
0228 #endif
0229 #ifdef OPTICKS_OGLRAP
0230     OGLRAP_LOG::Initialize(instance->prefixlevel_parse( max_level, "OGLRAP"), app1, NULL );
0231 #endif
0232 #ifdef OPTICKS_OKGL
0233     OKGL_LOG::Initialize(instance->prefixlevel_parse( max_level, "OKGL"), app1, NULL );
0234 #endif
0235 #ifdef OPTICKS_OK
0236     OK_LOG::Initialize(instance->prefixlevel_parse( max_level, "OK"), app1, NULL );
0237 #endif
0238 #ifdef OPTICKS_X4
0239     X4_LOG::Initialize(instance->prefixlevel_parse( max_level, "X4"), app1, NULL );
0240 #endif
0241 #ifdef OPTICKS_CFG4
0242     CFG4_LOG::Initialize(instance->prefixlevel_parse( max_level, "CFG4"), app1, NULL );
0243 #endif
0244 #ifdef OPTICKS_OKG4
0245     OKG4_LOG::Initialize(instance->prefixlevel_parse( max_level, "OKG4"), app1, NULL );
0246 #endif
0247 #ifdef OPTICKS_G4OK
0248     G4OK_LOG::Initialize(instance->prefixlevel_parse( max_level, "G4OK"), app1, NULL );
0249 #endif
0250 
0251 #ifdef OPTICKS_CSG
0252     CSG_LOG::Initialize(instance->prefixlevel_parse( max_level, "CSG"), app1, NULL );
0253 #endif
0254 
0255 
0256 #ifdef OPTICKS_CSG_GGEO
0257     CSG_GGEO_LOG::Initialize(instance->prefixlevel_parse( max_level, "CSG_GGEO"), app1, NULL );
0258 #endif
0259 #ifdef OPTICKS_GEOCHAIN
0260     GEOCHAIN_LOG::Initialize(instance->prefixlevel_parse( max_level, "GEOCHAIN"), app1, NULL );
0261 #endif
0262 #ifdef OPTICKS_QUDARAP
0263     QUDARAP_LOG::Initialize(instance->prefixlevel_parse( max_level, "QUDARAP"), app1, NULL );
0264 #endif
0265 #ifdef OPTICKS_CSGOPTIX
0266     CSGOPTIX_LOG::Initialize(instance->prefixlevel_parse( max_level, "CSGOPTIX"), app1, NULL );
0267 #endif
0268 
0269 #ifdef OPTICKS_GDXML
0270     GDXML_LOG::Initialize(instance->prefixlevel_parse( max_level, "GDXML"), app1, NULL );
0271 #endif
0272 
0273 #ifdef OPTICKS_G4CX
0274     G4CX_LOG::Initialize(instance->prefixlevel_parse( max_level, "G4CX"), app1, NULL );
0275 #endif
0276 
0277 
0278 
0279 
0280 
0281        }
0282        // checking the loggers in each subproj by emitting message at all loglevels
0283        static void Check()
0284        {
0285 #ifdef OPTICKS_SYSRAP
0286     printf("%s\n", "OPTICKS_SYSRAP" ); 
0287     SYSRAP_LOG::Check("SYSRAP");
0288 #else
0289     printf("%s\n", "!OPTICKS_SYSRAP" ); 
0290 #endif
0291 #ifdef OPTICKS_U4
0292     printf("%s\n", "OPTICKS_U4" ); 
0293     U4_LOG::Check("U4");
0294 #else
0295     printf("%s\n", "!OPTICKS_U4" ); 
0296 #endif
0297 #ifdef OPTICKS_BRAP
0298     printf("%s\n", "OPTICKS_BRAP" ); 
0299     BRAP_LOG::Check("BRAP");
0300 #else
0301     printf("%s\n", "!OPTICKS_BRAP" ); 
0302 #endif
0303 #ifdef OPTICKS_NPY
0304     printf("%s\n", "OPTICKS_NPY" ); 
0305     NPY_LOG::Check("NPY");
0306 #else
0307     printf("%s\n", "!OPTICKS_NPY" ); 
0308 #endif
0309 #ifdef OPTICKS_YOG
0310     printf("%s\n", "OPTICKS_YOG" ); 
0311     YOG_LOG::Check("YOG");
0312 #else
0313     printf("%s\n", "!OPTICKS_YOG" ); 
0314 #endif
0315 #ifdef OPTICKS_OKCORE
0316     printf("%s\n", "OPTICKS_OKCORE" ); 
0317     OKCORE_LOG::Check("OKCORE");
0318 #else
0319     printf("%s\n", "!OPTICKS_OKCORE" ); 
0320 #endif
0321 #ifdef OPTICKS_GGEO
0322     printf("%s\n", "OPTICKS_GGEO" ); 
0323     GGEO_LOG::Check("GGEO");
0324 #else
0325     printf("%s\n", "!OPTICKS_GGEO" ); 
0326 #endif
0327 
0328 #ifdef OPTICKS_ASIRAP
0329     printf("%s\n", "OPTICKS_ASIRAP" ); 
0330     ASIRAP_LOG::Check("ASIRAP");
0331 #else
0332     printf("%s\n", "!OPTICKS_ASIRAP" ); 
0333 #endif
0334 #ifdef OPTICKS_MESHRAP
0335     printf("%s\n", "OPTICKS_MESHRAP" ); 
0336     MESHRAP_LOG::Check("MESHRAP");
0337 #else
0338     printf("%s\n", "!OPTICKS_MESHRAP" ); 
0339 #endif
0340 #ifdef OPTICKS_OKGEO
0341     printf("%s\n", "OPTICKS_OKGEO" ); 
0342     OKGEO_LOG::Check("OKGEO");
0343 #else
0344     printf("%s\n", "!OPTICKS_OKGEO" ); 
0345 #endif
0346 #ifdef OPTICKS_CUDARAP
0347     printf("%s\n", "OPTICKS_CUDARAP" ); 
0348     CUDARAP_LOG::Check("CUDARAP");
0349 #else
0350     printf("%s\n", "!OPTICKS_CUDARAP" ); 
0351 #endif
0352 #ifdef OPTICKS_THRAP
0353     printf("%s\n", "OPTICKS_THRAP" ); 
0354     THRAP_LOG::Check("THRAP");
0355 #else
0356     printf("%s\n", "!OPTICKS_THRAP" ); 
0357 #endif
0358 #ifdef OPTICKS_OXRAP
0359     printf("%s\n", "OPTICKS_OXRAP" ); 
0360     OXRAP_LOG::Check("OXRAP");
0361 #else
0362     printf("%s\n", "!OPTICKS_OXRAP" ); 
0363 #endif
0364 #ifdef OPTICKS_OKOP
0365     printf("%s\n", "OPTICKS_OKOP" ); 
0366     OKOP_LOG::Check("OKOP");
0367 #else
0368     printf("%s\n", "!OPTICKS_OKOP" ); 
0369 #endif
0370 #ifdef OPTICKS_OGLRAP
0371     printf("%s\n", "OPTICKS_OGLRAP" ); 
0372     OGLRAP_LOG::Check("OGLRAP");
0373 #else
0374     printf("%s\n", "!OPTICKS_OGLRAP" ); 
0375 #endif
0376 #ifdef OPTICKS_OKGL
0377     printf("%s\n", "OPTICKS_OKGL" ); 
0378     OKGL_LOG::Check("OKGL");
0379 #else
0380     printf("%s\n", "!OPTICKS_OKGL" ); 
0381 #endif
0382 #ifdef OPTICKS_OK
0383     printf("%s\n", "OPTICKS_OK" ); 
0384     OK_LOG::Check("OK");
0385 #else
0386     printf("%s\n", "!OPTICKS_OK" ); 
0387 #endif
0388 #ifdef OPTICKS_X4
0389     printf("%s\n", "OPTICKS_X4" ); 
0390     X4_LOG::Check("X4");
0391 #else
0392     printf("%s\n", "!OPTICKS_X4" ); 
0393 #endif
0394 #ifdef OPTICKS_CFG4
0395     printf("%s\n", "OPTICKS_CFG4" ); 
0396     CFG4_LOG::Check("CFG4");
0397 #else
0398     printf("%s\n", "!OPTICKS_CFG4" ); 
0399 #endif
0400 #ifdef OPTICKS_OKG4
0401     printf("%s\n", "OPTICKS_OKG4" ); 
0402     OKG4_LOG::Check("OKG4");
0403 #else
0404     printf("%s\n", "!OPTICKS_OKG4" ); 
0405 #endif
0406 #ifdef OPTICKS_G4OK
0407     printf("%s\n", "OPTICKS_G4OK" ); 
0408     G4OK_LOG::Check("G4OK");
0409 #else
0410     printf("%s\n", "!OPTICKS_G4OK" ); 
0411 #endif
0412 
0413 
0414 
0415 #ifdef OPTICKS_CSG
0416     printf("%s\n", "OPTICKS_CSG" ); 
0417     CSG_LOG::Check("CSG");
0418 #else
0419     printf("%s\n", "!OPTICKS_CSG" ); 
0420 #endif
0421 
0422 #ifdef OPTICKS_CSG_GGEO
0423     printf("%s\n", "OPTICKS_CSG_GGEO" ); 
0424     CSG_GGEO_LOG::Check("CSG_GGEO");
0425 #else
0426     printf("%s\n", "!OPTICKS_CSG_GGEO" ); 
0427 #endif
0428 
0429 #ifdef OPTICKS_GEOCHAIN
0430     printf("%s\n", "OPTICKS_GEOCHAIN" ); 
0431     GEOCHAIN_LOG::Check("GEOCHAIN");
0432 #else
0433     printf("%s\n", "!OPTICKS_GEOCHAIN" ); 
0434 #endif
0435 
0436 #ifdef OPTICKS_QUDARAP
0437     printf("%s\n", "OPTICKS_QUDARAP" ); 
0438     QUDARAP_LOG::Check("QUDARAP");
0439 #else
0440     printf("%s\n", "!OPTICKS_QUDARAP" ); 
0441 #endif
0442 
0443 #ifdef OPTICKS_CSGOPTIX
0444     printf("%s\n", "OPTICKS_CSGOPTIX" ); 
0445     CSGOPTIX_LOG::Check("CSGOPTIX");
0446 #else
0447     printf("%s\n", "!OPTICKS_CSGOPTIX" ); 
0448 #endif
0449 
0450 #ifdef OPTICKS_GDXML
0451     printf("%s\n", "OPTICKS_GDXML" ); 
0452     GDXML_LOG::Check("GDXML");
0453 #else
0454     printf("%s\n", "!OPTICKS_GDXML" ); 
0455 #endif
0456 
0457 
0458 #ifdef OPTICKS_G4CX
0459     printf("%s\n", "OPTICKS_G4CX" ); 
0460     G4CX_LOG::Check("G4CX");
0461 #else
0462     printf("%s\n", "!OPTICKS_G4CX" ); 
0463 #endif
0464 
0465 
0466 
0467 
0468 
0469 
0470        }
0471 };
0472 
0473 #define OPTICKS_LOG_COLOR__(argc, argv) {      SLOG_COLOR(argc, argv);     OPTICKS_LOG_::Initialize(SLOG::instance, plog::get(), NULL ); }  
0474 #define OPTICKS_LOG__(argc, argv) {            SLOG_(     argc, argv);     OPTICKS_LOG_::Initialize(SLOG::instance, plog::get(), NULL ); } 
0475 #define OPTICKS_LOG(argc, argv) {              SLOG_COLOR(argc, argv);     OPTICKS_LOG_::Initialize(SLOG::instance, plog::get(), NULL ); } 
0476 #define OPTICKS_ELOG(name) {                   SLOG_ECOLOR(name);          OPTICKS_LOG_::Initialize(SLOG::instance, plog::get(), NULL ); } 
0477 
0478 
0479 /**
0480 OPTICKS_LOG macro is used from the main
0481 ------------------------------------------
0482 
0483 SLOG_COLOR(argc, argv) 
0484     instanciates SLOG and appenders::
0485 
0486         SLOG* _plog = new SLOG(argc, argv);
0487         static plog::RollingFileAppender<plog::TxtFormatter> 
0488         static plog::ColorConsoleAppender<plog::TxtFormatter> 
0489 
0490 OPTICKS_LOG_::Initialize(SLOG::instance, plog::get(), NULL )
0491 
0492 
0493 
0494 
0495 
0496 
0497 **/
0498 
0499 
0500