Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-06-10 01:53:51

0001 #ifndef L1Trigger_Phase2L1ParticleFlow_dbgPrintf_h
0002 #define L1Trigger_Phase2L1ParticleFlow_dbgPrintf_h
0003 
0004 #ifdef CMSSW_GIT_HASH
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include <string>
0007 
0008 inline edm::LogPrint dbgCout() { return edm::LogPrint("L1TCorrelator"); }
0009 inline edm::LogProblem dbgCerr() { return edm::LogProblem("L1TCorrelator"); }
0010 
0011 template <typename... Args>
0012 inline void dbgPrintf(const char *formatString, Args &&...args) {
0013   char buff[1024];
0014   std::fill(buff, buff + 1024, '\0');
0015   int ret = snprintf(buff, 1023, formatString, std::forward<Args>(args)...);
0016   if (ret > 0 && ret < 1023 && buff[ret - 1] == '\n')
0017     buff[ret - 1] = '\0';
0018   edm::LogPrint("L1TCorrelator") << std::string_view(buff);
0019 }
0020 
0021 #else  // outside CMSSW: just use std::cout and printf
0022 
0023 #include <iostream>
0024 
0025 inline std::ostream &dbgCout() { return std::cout; }
0026 inline std::ostream &dbgCerr() { return std::cerr; }
0027 
0028 template <typename... Args>
0029 inline void dbgPrintf(const char *formatString, Args &&...args) {
0030   printf(formatString, std::forward<Args>(args)...);
0031 }
0032 
0033 #endif
0034 
0035 #endif