mirror of
https://github.com/polybar/polybar.git
synced 2024-11-25 13:55:47 -05:00
logger: Output INFO messages as default
This commit is contained in:
parent
4b2d2fc986
commit
ff7e15db88
4 changed files with 25 additions and 22 deletions
|
@ -18,14 +18,12 @@ struct RegistryModuleEntry
|
|||
|
||||
class Registry
|
||||
{
|
||||
// Stopped and no loaded modules
|
||||
const int STAGE_1 = 1;
|
||||
// Modules loaded but waiting for initial broadcast
|
||||
const int STAGE_2 = 2;
|
||||
// Running
|
||||
const int STAGE_3 = 3;
|
||||
// Unloading modules
|
||||
const int STAGE_4 = 4;
|
||||
const int STAGE_1 = 1; // Stopped and no loaded modules
|
||||
const int STAGE_2 = 2; // Modules loaded but waiting for initial broadcast
|
||||
const int STAGE_3 = 3; // Running
|
||||
const int STAGE_4 = 4; // Unloading modules
|
||||
|
||||
std::shared_ptr<Logger> logger;
|
||||
|
||||
concurrency::Atomic<int> stage;
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ class Logger
|
|||
{
|
||||
std::mutex mtx;
|
||||
|
||||
int level = LogLevel::LEVEL_ERROR | LogLevel::LEVEL_WARNING;
|
||||
int level = LogLevel::LEVEL_ERROR | LogLevel::LEVEL_WARNING | LogLevel::LEVEL_INFO;
|
||||
int fd = LOGGER_FD;
|
||||
|
||||
public:
|
||||
|
|
|
@ -37,7 +37,7 @@ void EventLoop::start()
|
|||
if (this->state() == STATE_STARTED)
|
||||
return;
|
||||
|
||||
this->logger->info("Starting event loop...");
|
||||
this->logger->debug("Starting event loop...");
|
||||
|
||||
this->bar->load();
|
||||
this->registry->load();
|
||||
|
@ -46,6 +46,8 @@ void EventLoop::start()
|
|||
|
||||
this->t_write = std::thread(&EventLoop::loop_write, this);
|
||||
this->t_read = std::thread(&EventLoop::loop_read, this);
|
||||
|
||||
this->logger->debug("Event loop started...");
|
||||
}
|
||||
|
||||
void EventLoop::stop()
|
||||
|
@ -53,6 +55,8 @@ void EventLoop::stop()
|
|||
if (this->state() == STATE_STOPPED)
|
||||
return;
|
||||
|
||||
this->logger->debug("Stopping event loop...");
|
||||
|
||||
this->state = STATE_STOPPED;
|
||||
|
||||
// break the input read block - totally how it's meant to be done!
|
||||
|
@ -62,7 +66,8 @@ void EventLoop::stop()
|
|||
}
|
||||
|
||||
this->registry->unload();
|
||||
this->logger->info("Event loop stopped...");
|
||||
|
||||
this->logger->debug("Event loop stopped...");
|
||||
}
|
||||
|
||||
void EventLoop::wait()
|
||||
|
@ -225,7 +230,7 @@ void EventLoop::write_stdout()
|
|||
|
||||
void EventLoop::cleanup(int timeout_ms)
|
||||
{
|
||||
log_info("Cleaning up...");
|
||||
this->logger->debug("Cleaning up...");
|
||||
|
||||
std::atomic<bool> t_read_joined(false);
|
||||
std::atomic<bool> t_write_joined(false);
|
||||
|
|
|
@ -10,9 +10,9 @@ std::shared_ptr<Registry> &get_registry()
|
|||
return registry;
|
||||
}
|
||||
|
||||
Registry::Registry()
|
||||
Registry::Registry() : logger(get_logger())
|
||||
{
|
||||
get_logger()->debug("Entering STAGE 1");
|
||||
this->logger->debug("Entering STAGE 1");
|
||||
this->stage = STAGE_1;
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ bool Registry::ready()
|
|||
|
||||
if (stage == STAGE_2)
|
||||
for (auto &&entry : this->modules)
|
||||
if (!entry->warmedup) get_logger()->debug("Waiting for: "+ entry->module->name());
|
||||
if (!entry->warmedup) this->logger->debug("Waiting for: "+ entry->module->name());
|
||||
|
||||
return stage == STAGE_3;
|
||||
}
|
||||
|
@ -38,11 +38,11 @@ void Registry::load()
|
|||
if (this->stage() != STAGE_1)
|
||||
return;
|
||||
|
||||
get_logger()->debug("Entering STAGE 2");
|
||||
this->logger->debug("Entering STAGE 2");
|
||||
|
||||
this->stage = STAGE_2;
|
||||
|
||||
get_logger()->debug("Loading modules");
|
||||
this->logger->debug("Loading modules");
|
||||
|
||||
for (auto &&entry : this->modules) {
|
||||
std::lock_guard<std::mutex> wait_lck(this->wait_mtx);
|
||||
|
@ -56,11 +56,11 @@ void Registry::unload()
|
|||
if (this->stage() != STAGE_3)
|
||||
return;
|
||||
|
||||
get_logger()->debug("Entering STAGE 4");
|
||||
this->logger->debug("Entering STAGE 4");
|
||||
|
||||
this->stage = STAGE_4;
|
||||
|
||||
get_logger()->debug("Unloading modules");
|
||||
this->logger->debug("Unloading modules");
|
||||
|
||||
// Release wait lock
|
||||
{
|
||||
|
@ -95,8 +95,8 @@ bool Registry::wait()
|
|||
continue;
|
||||
}
|
||||
|
||||
get_logger()->info("Received initial broadcast from all modules");
|
||||
get_logger()->debug("Entering STAGE 3");
|
||||
this->logger->debug("Received initial broadcast from all modules");
|
||||
this->logger->debug("Entering STAGE 3");
|
||||
|
||||
this->stage = STAGE_3;
|
||||
break;
|
||||
|
@ -136,7 +136,7 @@ void Registry::notify(const std::string& module_name)
|
|||
mod_entry->module->refresh();
|
||||
} catch (Exception &e) {
|
||||
log_trace("Exception occurred in runner thread for: "+ module_name);
|
||||
get_logger()->error(e.what());
|
||||
this->logger->error(e.what());
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue