Skip to main content

Post-processing tools 2023 R2

logger_verbose.h

Last update: 17.04.2023
Go to the documentation of this file.
1 /**************************************************************
2 *
3 * (C) 2022 ANSYS, Inc. Unauthorized use, distribution, or duplication is prohibited.
4 *
5 * Restricted Rights Legend
6 *
7 * Use, duplication, or disclosure of this
8 * software and its documentation by the
9 * Government is subject to restrictions as
10 * set forth in subdivision [(b)(3)(ii)] of
11 * the Rights in Technical Data and Computer
12 * Software clause at 52.227-7013.
13 *
14 **************************************************************
15 */
16 
24 #ifndef ___DVS_LOGGER_VERBOSE_CONCRETE_H___
25 #define ___DVS_LOGGER_VERBOSE_CONCRETE_H___
26 
27 #include "logger_interface.h"
29 #include <stdarg.h>
30 #include <cstdio>
31 
32 namespace DVS
33 {
34 
39 class LoggerVerbose : public ILogger
40 {
41 public:
42 
49  LoggerVerbose(void* user_data, dvs_verbosity level, dvs_log_func func)
50  : _user_data(user_data), _level(level), _func(func)
51  {}
52 
57  virtual ~LoggerVerbose() = default; // make dtor virtual
58 
74  LoggerVerbose(const LoggerVerbose&) = default;
81 
93  void log(int level, const char* msg, ...) override
94  {
95  if (_func && (level <= _level))
96  {
97  char buffer[1024];
98  va_list args;
99  va_start (args, msg);
100  vsnprintf(buffer, 1024, msg, args);
101  va_end (args);
102  _func(_user_data, buffer);
103  }
104  }
105 
110  void release() override
111  {
112  delete this;
113  }
114 
115 private:
116 
117  void* _user_data;
118  dvs_verbosity _level;
119  dvs_log_func _func;
120 };
121 }
122 
123 #endif //___DVS_LOGGER_VERBOSE_CONCRETE_H___
Interface for a logger to be used by DVS::IClient.
Logger class based on verbosity.
LoggerVerbose(LoggerVerbose &&)=default
Support moving.
void release() override
Release this logger.
LoggerVerbose & operator=(const LoggerVerbose &)=default
LoggerVerbose & operator=(LoggerVerbose &&)=default
LoggerVerbose(void *user_data, dvs_verbosity level, dvs_log_func func)
Constructor.
virtual ~LoggerVerbose()=default
Virtual DTOR.
void log(int level, const char *msg,...) override
Log a message to the logger.
LoggerVerbose(const LoggerVerbose &)=default
Support copying.
C API for using Dynamic Visualization Store.
void(* dvs_log_func)(void *, const char *)
Function pointer for logging methods.
dvs_verbosity
Verbosity levels.
Logger Interface Class.