CMS 3D CMS Logo

dbgPrintf.h
Go to the documentation of this file.
1 #ifndef L1Trigger_Phase2L1ParticleFlow_dbgPrintf_h
2 #define L1Trigger_Phase2L1ParticleFlow_dbgPrintf_h
3 
4 #ifdef CMSSW_GIT_HASH
6 #include <string>
7 
8 inline edm::LogPrint dbgCout() { return edm::LogPrint("L1TCorrelator"); }
9 inline edm::LogProblem dbgCerr() { return edm::LogProblem("L1TCorrelator"); }
10 
11 template <typename... Args>
12 inline void dbgPrintf(const char *formatString, Args &&...args) {
13  char buff[1024];
14  std::fill(buff, buff + 1024, '\0');
15  int ret = snprintf(buff, 1023, formatString, std::forward<Args>(args)...);
16  if (ret > 0 && ret < 1023 && buff[ret - 1] == '\n')
17  buff[ret - 1] = '\0';
18  edm::LogPrint("L1TCorrelator") << std::string_view(buff);
19 }
20 
21 #else // outside CMSSW: just use std::cout and printf
22 
23 #include <iostream>
24 
25 inline std::ostream &dbgCout() { return std::cout; }
26 inline std::ostream &dbgCerr() { return std::cerr; }
27 
28 template <typename... Args>
29 inline void dbgPrintf(const char *formatString, Args &&...args) {
30  printf(formatString, std::forward<Args>(args)...);
31 }
32 
33 #endif
34 
35 #endif
ret
prodAgent to be discontinued
void dbgPrintf(const char *formatString, Args &&...args)
Definition: dbgPrintf.h:29
std::ostream & dbgCout()
Definition: dbgPrintf.h:25
Log< level::Warning, true > LogPrint
std::ostream & dbgCerr()
Definition: dbgPrintf.h:26
Log< level::Error, true > LogProblem