Skip to content

Commit

Permalink
Fixed bootloop issue (see #7)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheStaticTurtle committed Sep 3, 2022
1 parent 4e63880 commit a8000c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions syslog_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ void SyslogComponent::setup() {
#ifdef USE_LOGGER
if (logger::global_logger != nullptr) {
logger::global_logger->add_on_log_callback([this](int level, const char *tag, const char *message) {
if(!this->enable_logger ||
(level > this->settings_.min_log_level)) return;
if(!this->enable_logger || (level > this->settings_.min_log_level)) return;
if(this->strip_colors) { //Strips the "033[0;xxx" at the beginning and the "#033[0m" at the end of log messages
std::string org_msg(message);
this->log(level, tag, org_msg.substr(7, org_msg.size() -7 -4));
Expand All @@ -53,6 +52,8 @@ void SyslogComponent::loop() {
void SyslogComponent::log(uint8_t level, const std::string &tag, const std::string &payload) {
level = level > 7 ? 7 : level;

if(this->udp_ == NULL) return; //Make sure that we have gone through the setup and have an WifiUDP instance here.

Syslog syslog(
*this->udp_,
this->settings_.address.c_str(),
Expand All @@ -65,7 +66,7 @@ void SyslogComponent::log(uint8_t level, const std::string &tag, const std::stri
}

float SyslogComponent::get_setup_priority() const {
return setup_priority::LATE;
return setup_priority::AFTER_WIFI;
}

} // namespace syslog
Expand Down
2 changes: 1 addition & 1 deletion syslog_component.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SyslogComponent : public Component {
bool strip_colors;
bool enable_logger;
SYSLOGSettings settings_;
UDP *udp_;
UDP *udp_ = NULL;
};

template<typename... Ts> class SyslogLogAction : public Action<Ts...> {
Expand Down

0 comments on commit a8000c7

Please sign in to comment.