Skip to content

possibility to disable logging #35

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/ConnectionManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
#ifndef CONNECTION_MANAGER_H_INCLUDED
#define CONNECTION_MANAGER_H_INCLUDED

#ifndef ARDUINO_CLOUD_DEBUG_LEVEL
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd leave the guard to allow multiple inclusion of this file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@facchinm this is only to define a default in case it wasn't defined in the sketch, but it's definitely not needed anymore.
there's still a check against multiple inclusion

#define ARDUINO_CLOUD_DEBUG_LEVEL 2
#endif

#include <Client.h>

Expand Down Expand Up @@ -77,7 +75,10 @@ class ConnectionManager {
#endif

static int debugMessageLevel = ARDUINO_CLOUD_DEBUG_LEVEL;
inline void debugMessage(char *_msg, uint8_t _debugLevel, bool _timestamp = true, bool _newline = true) {
inline void debugMessage(char *_msg, int _debugLevel, bool _timestamp = true, bool _newline = true) {
if(_debugLevel < 0){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this check is probably not needed if we only allow messages from 0 up 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mh... better safe than sorry? :)

return;
}
if (_debugLevel <= debugMessageLevel) {
char prepend[20];
sprintf(prepend, "\n[ %d ] ", millis());
Expand All @@ -92,7 +93,7 @@ inline void debugMessage(char *_msg, uint8_t _debugLevel, bool _timestamp = true
}
}

inline void setDebugMessageLevel(uint8_t _debugLevel){
inline void setDebugMessageLevel(int _debugLevel){
debugMessageLevel = _debugLevel;
}
#endif