libcyberradio 22.01.24
Debuggable.h
1/* -*- c++ -*- */
2/***************************************************************************
3 * \file Debuggable.h
4 *
5 * \brief Class that supports debug output.
6 *
7 * \author DA
8 * \copyright 2017 CyberRadio Solutions, Inc.
9 */
10
11#ifndef INCLUDED_LIBCYBERRADIO_DEBUGGABLE_H_
12#define INCLUDED_LIBCYBERRADIO_DEBUGGABLE_H_
13
14#include <string>
15#include <stdio.h>
16
20#define DEBUG_FP stderr
24#define DEBUG_TIME_FMT "%H:%M:%S"
25
26
30namespace LibCyberRadio
31{
39 {
40 public:
51 bool debug = false,
52 const std::string& debug_name = "",
53 FILE* debug_fp = DEBUG_FP,
54 const std::string& debug_timefmt = DEBUG_TIME_FMT
55 );
59 virtual ~Debuggable();
64 Debuggable(const Debuggable& other);
70 Debuggable& operator=(const Debuggable& other);
79 virtual void setDebugName(
80 const std::string& debug_name
81 );
87 virtual void setDebugFile(
88 FILE* debug_fp
89 );
96 virtual void setDebugTimeFormat(
97 const std::string& debug_timefmt
98 );
111 virtual int debug(
112 const char *format,
113 ...
114 );
120 virtual const char* debugBool(
121 bool x
122 );
127 virtual bool isDebug() const;
132 virtual std::string getDebugName() const;
146 virtual std::string rawString(const std::string& data);
147
148 protected:
149 bool _debug;
150 std::string _debugName;
151 FILE* _debugFp;
152 std::string _debugTimeFmt;
153 char* _debugTimestamp;
154 size_t _debugTimestampSize;
155 };
156
157} /* namespace LibCyberRadio */
158
159#endif /* INCLUDED_LIBCYBERRADIO_DEBUGGABLE_H_ */
virtual ~Debuggable()
Destroys a Debuggable object.
virtual void setDebugTimeFormat(const std::string &debug_timefmt)
Sets the debug time format for this object.
virtual void setDebugFile(FILE *debug_fp)
Sets the debug file pointer for this object.
Debuggable & operator=(const Debuggable &other)
Assignment operator for Debuggable objects.
virtual std::string getDebugName() const
Gets the debug name for this object.
virtual std::string rawString(const std::string &data)
Gets a "raw" string representation of a given data string.
virtual const char * debugBool(bool x)
Gets a debug output string for a Boolean value.
virtual void setDebugName(const std::string &debug_name)
Sets the debug name for this object.
virtual bool isDebug() const
Gets whether this object produces debug output.
virtual int debug(const char *format,...)
Outputs debug information.
Debuggable(bool debug=false, const std::string &debug_name="", FILE *debug_fp=DEBUG_FP, const std::string &debug_timefmt=DEBUG_TIME_FMT)
Constructs a Debuggable object.
Defines functionality for LibCyberRadio applications.
Definition App.h:24