Debug.h
Go to the documentation of this file.
1 /****
2  * Sming Framework Project - Open Source framework for high efficiency native ESP8266 development.
3  * Created 2015 by Skurydin Alexey
4  * http://github.com/SmingHub/Sming
5  * All files of the Sming Core are provided under the LGPL v3 license.
6  *
7  * Debug.h
8  *
9  ****/
10 
11 #pragma once
12 
13 #include "HardwareSerial.h"
14 #include "Clock.h"
15 #include "WString.h"
17 
23 
29  Stream* debugStream{nullptr};
30 };
31 
35 enum eDBGPrefix {
38 };
39 
50 class DebugClass : public Print
51 {
52 public:
56  DebugClass();
57 
60  void initCommand();
61 
64  void start();
65 
68  void stop();
69 
73  bool status()
74  {
75  return started;
76  }
77 
82  void setDebug(DebugPrintCharDelegate reqDelegate);
83 
88  void setDebug(Stream& reqStream);
89 
90  /* implementation of write for Print Class */
91  size_t write(uint8_t) override;
92 
93 private:
94  bool started = false;
95  bool useDebugPrefix = true;
96  bool newDebugLine = true;
97  DebugOuputOptions debugOut;
98  void printPrefix();
99  void processDebugCommands(String commandLine, CommandOutput* commandOutput);
100 };
101 
110 extern DebugClass Debug;
111 
CommandLine commandLine
Stream * debugStream
Debug output stream.
Definition: Debug.h:29
Provides debug output to stream (e.g. Serial) or delegate function handler.
Definition: Debug.h:50
The String class.
Definition: WString.h:136
DebugPrintCharDelegate debugDelegate
Function to handle debug output.
Definition: Debug.h:28
Provides formatted output to stream.
Definition: Print.h:36
Do not use debug prefix.
Definition: Debug.h:36
DebugClass Debug
Global instance of Debug object.
Definition: CommandOutput.h:18
eDBGPrefix
Debug prefix state.
Definition: Debug.h:35
Structure for debug options.
Definition: Debug.h:27
Use debug prefix.
Definition: Debug.h:37
bool status()
Get debug status.
Definition: Debug.h:73
Base Stream class.
Definition: Stream.h:32