From 554f25608fc467f8f04ca16b32c16380682ebfed Mon Sep 17 00:00:00 2001 From: Snaipe Date: Wed, 4 Nov 2015 20:18:47 +0100 Subject: [PATCH] Refactored output_provider -> logger, and moved actual output providers to io/ --- CMakeLists.txt | 8 +++++--- doc/internal.rst | 14 +++++++------- include/criterion/logging.h | 4 ++-- include/criterion/options.h | 2 +- src/core/report.h | 2 +- src/core/runner.c | 2 +- src/entry/main.c | 2 +- src/entry/options.c | 2 +- src/{log => io}/output.c | 0 src/{log => io}/output.h | 0 src/{log => io}/tap.c | 2 -- src/{log => io}/xml.c | 0 src/log/normal.c | 2 +- 13 files changed, 20 insertions(+), 20 deletions(-) rename src/{log => io}/output.c (100%) rename src/{log => io}/output.h (100%) rename src/{log => io}/tap.c (98%) rename src/{log => io}/xml.c (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index e5baa7b..dd56870 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,11 +127,12 @@ set(SOURCE_FILES src/io/event.h src/io/asprintf.c src/io/file.c + src/io/output.c + src/io/output.h + src/io/tap.c + src/io/xml.c src/log/logging.c - src/log/output.c - src/log/tap.c src/log/normal.c - src/log/xml.c src/string/i18n.c src/string/i18n.h src/entry/options.c @@ -168,6 +169,7 @@ set(INTERFACE_FILES include/criterion/alloc.h include/criterion/parameterized.h include/criterion/redirect.h + include/criterion/output.h ) # Generate the configure file diff --git a/doc/internal.rst b/doc/internal.rst index 69b5f0a..f129628 100644 --- a/doc/internal.rst +++ b/doc/internal.rst @@ -28,7 +28,7 @@ Field Type Description =================== ================================== ============================================================== logging_threshold enum criterion_logging_level The logging level ------------------- ---------------------------------- -------------------------------------------------------------- -output_provider struct criterion_output_provider * The output provider (see below) +logger struct criterion_logger * The logger (see below) ------------------- ---------------------------------- -------------------------------------------------------------- no_early_exit bool True iff the test worker should exit early ------------------- ---------------------------------- -------------------------------------------------------------- @@ -75,15 +75,15 @@ Example main return result; } -Implementing your own output provider -------------------------------------- +Implementing your own logger +---------------------------- -In case you are not satisfied by the default output provider, you can implement -yours. To do so, simply set the ``output_provider`` option to your custom -output provider. +In case you are not satisfied by the default logger, you can implement +yours. To do so, simply set the ``logger`` option to your custom +logger. Each function contained in the structure is called during one of the standard phase of the criterion runner. -For more insight on how to implement this, see other existing output providers +For more insight on how to implement this, see other existing loggers in ``src/log/``. diff --git a/include/criterion/logging.h b/include/criterion/logging.h index 2e07f43..3fbc27c 100644 --- a/include/criterion/logging.h +++ b/include/criterion/logging.h @@ -103,7 +103,7 @@ CR_API void criterion_log(enum criterion_logging_level level, const char *msg, . # define criterion_perror(...) criterion_plog(CRITERION_IMPORTANT, CRITERION_PREFIX_ERR, __VA_ARGS__) -struct criterion_output_provider { +struct criterion_logger { void (*log_pre_all )(struct criterion_test_set *set); void (*log_pre_suite )(struct criterion_suite_set *set); void (*log_pre_init )(struct criterion_test *test); @@ -121,7 +121,7 @@ struct criterion_output_provider { void (*log_post_all )(struct criterion_global_stats *stats); }; -extern struct criterion_output_provider normal_logging; +extern struct criterion_logger normal_logging; CR_END_C_API diff --git a/include/criterion/options.h b/include/criterion/options.h index ee3a9c3..220e32c 100644 --- a/include/criterion/options.h +++ b/include/criterion/options.h @@ -29,7 +29,7 @@ struct criterion_options { enum criterion_logging_level logging_threshold; - struct criterion_output_provider *output_provider; + struct criterion_logger *logger; bool no_early_exit; bool always_succeed; bool use_ascii; diff --git a/src/core/report.h b/src/core/report.h index dfee5ba..aa545ea 100644 --- a/src/core/report.h +++ b/src/core/report.h @@ -46,7 +46,7 @@ DECL_CALL_REPORT_HOOKS(POST_SUITE); DECL_CALL_REPORT_HOOKS(POST_ALL); #define log(Type, ...) \ - log_(criterion_options.output_provider->log_ ## Type, __VA_ARGS__); + log_(criterion_options.logger->log_ ## Type, __VA_ARGS__); #define log_(Log, ...) \ (Log ? Log(__VA_ARGS__) : nothing()); diff --git a/src/core/runner.c b/src/core/runner.c index 7a87b81..6ebae26 100644 --- a/src/core/runner.c +++ b/src/core/runner.c @@ -37,7 +37,7 @@ #include "wrappers/wrap.h" #include "string/i18n.h" #include "io/event.h" -#include "log/output.h" +#include "io/output.h" #include "runner_coroutine.h" #include "stats.h" #include "runner.h" diff --git a/src/entry/main.c b/src/entry/main.c index e6c9722..6a73b37 100644 --- a/src/entry/main.c +++ b/src/entry/main.c @@ -30,7 +30,7 @@ #include "criterion/options.h" #include "criterion/ordered-set.h" #include "core/runner.h" -#include "log/output.h" +#include "io/output.h" #include "config.h" #include "common.h" diff --git a/src/entry/options.c b/src/entry/options.c index 20295f9..0569a40 100644 --- a/src/entry/options.c +++ b/src/entry/options.c @@ -25,6 +25,6 @@ struct criterion_options criterion_options = { .logging_threshold = CRITERION_IMPORTANT, - .output_provider = &normal_logging, + .logger = &normal_logging, .measure_time = true, }; diff --git a/src/log/output.c b/src/io/output.c similarity index 100% rename from src/log/output.c rename to src/io/output.c diff --git a/src/log/output.h b/src/io/output.h similarity index 100% rename from src/log/output.h rename to src/io/output.h diff --git a/src/log/tap.c b/src/io/tap.c similarity index 98% rename from src/log/tap.c rename to src/io/tap.c index 779707d..6c7b797 100644 --- a/src/log/tap.c +++ b/src/io/tap.c @@ -26,9 +26,7 @@ #include #include #include "criterion/stats.h" -#include "criterion/logging.h" #include "criterion/options.h" -#include "criterion/ordered-set.h" #include "compat/posix.h" #include "compat/strtok.h" #include "compat/time.h" diff --git a/src/log/xml.c b/src/io/xml.c similarity index 100% rename from src/log/xml.c rename to src/io/xml.c diff --git a/src/log/normal.c b/src/log/normal.c index f7319d3..9789d27 100644 --- a/src/log/normal.c +++ b/src/log/normal.c @@ -233,7 +233,7 @@ void normal_log_test_abort(CR_UNUSED struct criterion_test_stats *stats, const c free(dup); } -struct criterion_output_provider normal_logging = { +struct criterion_logger normal_logging = { .log_pre_all = normal_log_pre_all, .log_pre_init = normal_log_pre_init, .log_pre_suite = normal_log_pre_suite,