diff options
author | David Robillard <d@drobilla.net> | 2022-08-10 17:48:21 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-08-17 13:51:15 -0400 |
commit | 5f579de5d335681a97b3727c503e33b34d3c5ee7 (patch) | |
tree | 37a2007d980d794028f6cf37934dffcf1d1606ea /src | |
parent | dd0b73bf4e03359728b671d6a5725be30e05a9e9 (diff) | |
download | jalv-5f579de5d335681a97b3727c503e33b34d3c5ee7.tar.gz jalv-5f579de5d335681a97b3727c503e33b34d3c5ee7.tar.bz2 jalv-5f579de5d335681a97b3727c503e33b34d3c5ee7.zip |
Use logging API for almost all console output
Towards being smarter about this and maintaining distinction between kinds of
output, so the console interface can grow into a more solid language/protocol.
Diffstat (limited to 'src')
-rw-r--r-- | src/jack.c | 2 | ||||
-rw-r--r-- | src/jalv.c | 24 | ||||
-rw-r--r-- | src/jalv_console.c | 5 | ||||
-rw-r--r-- | src/log.c | 4 | ||||
-rw-r--r-- | src/log.h | 1 |
5 files changed, 22 insertions, 14 deletions
@@ -340,7 +340,7 @@ jalv_backend_init(Jalv* jalv) return NULL; } - printf("JACK Name: %s\n", jack_get_client_name(client)); + jalv_log(JALV_LOG_INFO, "JACK Name: %s\n", jack_get_client_name(client)); // Set audio engine properties jalv->sample_rate = (float)jack_get_sample_rate(client); @@ -784,7 +784,7 @@ jalv_apply_control_arg(Jalv* jalv, const char* s) } jalv_set_control(jalv, control, sizeof(float), jalv->urids.atom_Float, &val); - printf("%s = %f\n", sym, val); + jalv_log(JALV_LOG_INFO, "%s = %f\n", sym, val); return true; } @@ -1098,7 +1098,8 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) } // Find plugin - printf("Plugin: %s\n", lilv_node_as_string(plugin_uri)); + jalv_log( + JALV_LOG_INFO, "Plugin: %s\n", lilv_node_as_string(plugin_uri)); jalv->plugin = lilv_plugins_get_by_uri(plugins, plugin_uri); lilv_node_free(plugin_uri); if (!jalv->plugin) { @@ -1166,8 +1167,9 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) #endif if (jalv->ui) { - printf("UI: %s\n", - lilv_node_as_uri(lilv_ui_get_uri(jalv->ui))); + jalv_log(JALV_LOG_INFO, + "UI: %s\n", + lilv_node_as_uri(lilv_ui_get_uri(jalv->ui))); } } } @@ -1183,9 +1185,9 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) return -6; } - printf("Sample rate: %u Hz\n", (uint32_t)jalv->sample_rate); - printf("Block length: %u frames\n", jalv->block_length); - printf("MIDI buffers: %zu bytes\n", jalv->midi_buf_size); + jalv_log(JALV_LOG_INFO, "Sample rate: %u Hz\n", (uint32_t)jalv->sample_rate); + jalv_log(JALV_LOG_INFO, "Block length: %u frames\n", jalv->block_length); + jalv_log(JALV_LOG_INFO, "MIDI buffers: %zu bytes\n", jalv->midi_buf_size); if (jalv->opts.buffer_size == 0) { /* The UI ring is fed by plugin output ports (usually one), and the UI @@ -1216,9 +1218,9 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) // The UI can only go so fast, clamp to reasonable limits jalv->ui_update_hz = MIN(60, jalv->ui_update_hz); jalv->opts.buffer_size = MAX(4096, jalv->opts.buffer_size); - printf("Comm buffers: %u bytes\n", jalv->opts.buffer_size); - printf("Update rate: %.01f Hz\n", jalv->ui_update_hz); - printf("Scale factor: %.01f\n", jalv->ui_scale_factor); + jalv_log(JALV_LOG_INFO, "Comm buffers: %u bytes\n", jalv->opts.buffer_size); + jalv_log(JALV_LOG_INFO, "Update rate: %.01f Hz\n", jalv->ui_update_hz); + jalv_log(JALV_LOG_INFO, "Scale factor: %.01f\n", jalv->ui_scale_factor); // Build options array to pass to plugin const LV2_Options_Option options[ARRAY_SIZE(jalv->features.options)] = { @@ -1328,7 +1330,7 @@ jalv_open(Jalv* const jalv, int* argc, char*** argv) jalv_worker_start( jalv->state_worker, worker_iface, jalv->instance->lv2_handle); - printf("\n"); + jalv_log(JALV_LOG_INFO, "\n"); if (!jalv->buf_size_set) { jalv_allocate_port_buffers(jalv); } diff --git a/src/jalv_console.c b/src/jalv_console.c index 9ce009b..4d5f528 100644 --- a/src/jalv_console.c +++ b/src/jalv_console.c @@ -170,7 +170,10 @@ jalv_print_controls(Jalv* jalv, bool writable, bool readable) if ((control->is_writable && writable) || (control->is_readable && readable)) { struct Port* const port = &jalv->ports[control->index]; - printf("%s = %f\n", lilv_node_as_string(control->symbol), port->control); + jalv_log(JALV_LOG_INFO, + "%s = %f\n", + lilv_node_as_string(control->symbol), + port->control); } } @@ -28,7 +28,7 @@ jalv_print_control(Jalv* const jalv, const float value) { const LilvNode* sym = lilv_port_get_symbol(jalv->plugin, port->lilv_port); - printf("%s = %f\n", lilv_node_as_string(sym), value); + jalv_log(JALV_LOG_INFO, "%s = %f\n", lilv_node_as_string(sym), value); } char* @@ -67,6 +67,8 @@ jalv_vlog(const JalvLogLevel level, const char* const fmt, va_list ap) fancy = jalv_ansi_start(stderr, 33); fprintf(stderr, "warning: "); break; + case JALV_LOG_INFO: + break; case JALV_LOG_DEBUG: fancy = jalv_ansi_start(stderr, 32); fprintf(stderr, "trace: "); @@ -29,6 +29,7 @@ struct Port; typedef enum { JALV_LOG_ERR = 3, JALV_LOG_WARNING = 4, + JALV_LOG_INFO = 6, JALV_LOG_DEBUG = 7, } JalvLogLevel; |