Dangerous SNMP
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
logger.hpp
1 #pragma once
2 
3 #include <iostream>
4 
5 namespace dangerous { namespace snmp {
6 
14 class Logger {
15 public:
18  enum System {
19  GENERAL = 0, //<! Logging that has no particular category.
20  ENCODING, //<! Logging related to encoding messages.
24  IO,
28  MAX
29  };
30 
31 public:
36  Logger() {
37  for( int i = 0; i < MAX; i++ ) {
38  systems[ i ] = false;
39  }
40  }
41 
47  inline bool system( System system ) {
48  if( (int)system < (int)GENERAL ) {
49  return false;
50  }
51  if( (int)system >= (int)MAX ) {
52  return false;
53  }
54  return systems[ system ];
55  }
56 
62  inline void system( System system, bool enabled ) {
63  if( (int)system < (int)GENERAL ) {
64  return;
65  }
66  if( (int)system >= (int)MAX ) {
67  return;
68  }
69  //DEBUG: std::cout << "Logger::system: Setting system #" << (int)system << " to " << ( enabled ? "on" : "off" ) << std::endl;
70  systems[ system ] = enabled;
71  }
72 
77  inline std::ostream& out() {
78  return std::cout;
79  }
80 
81 protected:
84 };
85 
87 extern Logger logger;
88 
89 } }
90 
bool systems[Logger::MAX]
This is the mapping of the logging system to its on/off status.
Definition: logger.hpp:83
bool system(System system)
This returns the logging status for the given system.
Definition: logger.hpp:47
std::ostream & out()
This returns the output stream for the Logger.
Definition: logger.hpp:77
Placeholder for the maximum value of the enumeration.
Definition: logger.hpp:28
The Logger class is the mechanism by which Dangerous SNMP will perform logging operations.
Definition: logger.hpp:14
Logging related to parsing.
Definition: logger.hpp:23
Logging related to input/output.
Definition: logger.hpp:24
Logger()
Default constructor.
Definition: logger.hpp:36
Logger logger
We will expose a global Logger instance.
Logging related to decoding messages.
Definition: logger.hpp:21
void system(System system, bool enabled)
This enables or disables logging for the given system.
Definition: logger.hpp:62
System
This defines an enumeration for the various "systems" in Dangerous SNMP.
Definition: logger.hpp:18
Logging related to clients.
Definition: logger.hpp:26
Logging related to agents.
Definition: logger.hpp:27
Logging related to ByteStream.
Definition: logger.hpp:22
Logging related to transports.
Definition: logger.hpp:25