File indexing completed on 2026-04-09 07:49:18
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <cassert>
0021 #include "SLOG.hh"
0022 #include "SArgs.hh"
0023
0024 #include "SYSRAP_LOG.hh"
0025
0026
0027 int main(int argc, char** argv)
0028 {
0029 SLOG_(argc, argv);
0030 SYSRAP_LOG__ ;
0031
0032 plog::Severity level = info ;
0033
0034 sLOG(level, -3) << "-3" ;
0035 sLOG(level, -2) << "-2" ;
0036 sLOG(level, -1) << "-1" ;
0037 sLOG(level, 0) << "0" ;
0038 sLOG(level, 1) << "1" ;
0039 sLOG(level, 2) << "2" ;
0040 sLOG(level, 3) << "3" ;
0041
0042
0043
0044 std::cout << R"(
0045
0046
0047 Use sLOG(level, delta) to adjust logging level
0048 required for the output of the message relative to a base level.
0049 Note the inversion as are changing the level to get an output:
0050
0051 -ve : message will appear *more*
0052 +ve : message will appear *less*
0053
0054 This allows a base severity level to be set for a class,
0055 with some delta variations off that.
0056
0057 Usage::
0058
0059 plog::Severity m_level = info ; // typically class member with base severity
0060
0061 sLOG(m_level, -1) << "Decrease needed log level below base : so will appear more " ;
0062 sLOG(m_level, 0) << "Leave loglevel asis, same as LOG(m_level) << ... " ;
0063 sLOG(m_level, +1) << "Increase needed log level above base : so will appear less " ;
0064
0065
0066 This avoids manual adjustment of lots of output levels, whilst debugging a class
0067 up the base by fixing m_level eg m_level(info) and establish an output level
0068 structure :
0069
0070 * logging inside loops should have +1/+2 relative to base
0071 * infrequent high level flow output -2/-1 so they appear usually
0072
0073 Then once the class is behaving dial down m_level, to reduce output while
0074 still leaving the high level flow visible.
0075
0076 You can also of course change the cut, which adjusts all levels for the
0077 entire package not just the class being debugged:
0078
0079 OKX4Test --cfg4 debug
0080 OKX4Test --cfg4 warning
0081
0082
0083 To shut a class up set m_level(verbose) then only -2s will appear with
0084 default level of info
0085
0086
0087
0088
0089 Note the limited range::
0090
0091 enum Severity
0092 {
0093 none = 0,
0094 fatal = 1,
0095 error = 2,
0096 warning = 3,
0097 info = 4,
0098 debug = 5,
0099 verbose = 6
0100 };
0101
0102 )" ;
0103
0104
0105 return 0 ;
0106 }
0107
0108