Skip to content
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

Fix switchres bin logs #82

Merged
merged 2 commits into from May 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion log.cpp
Expand Up @@ -15,7 +15,7 @@
#include "log.h"

enum log_verbosity { NONE, ERROR, INFO, DEBUG };
static log_verbosity log_level = ERROR;
static log_verbosity log_level = INFO;

void log_dummy(const char *, ...) {}

Expand Down Expand Up @@ -49,4 +49,12 @@ void set_log_verbosity(int level)
if(level > DEBUG)
level = DEBUG;
log_level = (log_verbosity)level;

// Reinit loggers
if (log_level < DEBUG)
log_verbose = &log_dummy;
if (log_level < INFO)
log_info = &log_dummy;
if (log_level < ERROR)
log_error = &log_dummy;
}
6 changes: 6 additions & 0 deletions switchres.cpp
Expand Up @@ -107,6 +107,12 @@ switchres_manager::switchres_manager()

// Create our display manager
m_display_factory = new display_manager();

// Set logger properties
set_log_level(2);
set_log_info_fn((void*)printf);
set_log_error_fn((void*)printf);
set_log_verbose_fn((void*)printf);
}

//============================================================
Expand Down
2 changes: 1 addition & 1 deletion switchres.ini
Expand Up @@ -61,4 +61,4 @@ custom_timing auto
# 1: only errors
# 2: general information
# 3: debug messages
verbosity 1
verbosity 2
7 changes: 3 additions & 4 deletions switchres_main.cpp
Expand Up @@ -33,10 +33,6 @@ int main(int argc, char **argv)

switchres_manager switchres;

// Init logging
switchres.set_log_info_fn((void*)printf);
switchres.set_log_error_fn((void*)printf);

switchres.parse_config("switchres.ini");

int width = 0;
Expand Down Expand Up @@ -97,6 +93,9 @@ int main(int argc, char **argv)
switch (c)
{
case 'v':
switchres.set_log_level(3);
switchres.set_log_error_fn((void*)printf);
switchres.set_log_info_fn((void*)printf);
switchres.set_log_verbose_fn((void*)printf);
break;

Expand Down
3 changes: 0 additions & 3 deletions switchres_wrapper.cpp
Expand Up @@ -28,9 +28,6 @@ switchres_manager* swr;
MODULE_API void sr_init() {
setlocale(LC_NUMERIC, "C");
swr = new switchres_manager;
//swr->set_log_verbose_fn((void *)printf);
//swr->set_log_info_fn((void *)printf);
//swr->set_log_error_fn((void *)printf);
swr->parse_config("switchres.ini");
}

Expand Down