arduino-audio-driver
Loading...
Searching...
No Matches
AudioDriverLogger.h
Go to the documentation of this file.
1
2#pragma once
3#include "ConfigAudioDriver.h"
4#if AUDIO_DRIVER_LOGGIN_ACTVIE && !defined(AUDIO_DRIVER_LOGGING_IDF)
5
6#include "LoggerSTD.h"
8
9#ifdef ARDUINO
10# include "Print.h"
11#endif
12
13namespace audio_driver {
14
15// define supported log levels
16enum class AudioDriverLogLevel {Debug=0, Info=1, Warning=2, Error=3};
17
18
19/***
20 * C++ API to configure logging
21 */
22class AudioDriverLoggerClass {
23public:
24 void setLogLevel(AudioDriverLogLevel level){
25 LOGLEVEL_AUDIODRIVER = (int) level;
26 }
27#ifdef ARDUINO
28 void setOutput(Print& out) {
29 setAudioDriverLogOutput(&out);
30 }
31 bool begin(Print& out, AudioDriverLogLevel level) {
32 setLogLevel(level);
33 setOutput(out);
34 return true;
35 }
36#endif
37 bool begin(AudioDriverLogLevel level) {
38 setLogLevel(level);
39 return true;
40 }
41 void end(){
42 setAudioDriverLogOutput(nullptr);
43 }
44};
45
46// global object for std logging api
47static AudioDriverLoggerClass AudioDriverLogger;
48
49} // namespace audio_driver
50
51#endif
Namespace for audio driver components.
Definition AudioBoard.h:5