Refactored output_provider -> logger, and moved actual output providers to io/

This commit is contained in:
Snaipe 2015-11-04 20:18:47 +01:00
parent 8659994fa9
commit 554f25608f
13 changed files with 20 additions and 20 deletions

View file

@ -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

View file

@ -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/``.

View file

@ -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

View file

@ -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;

View file

@ -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());

View file

@ -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"

View file

@ -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"

View file

@ -25,6 +25,6 @@
struct criterion_options criterion_options = {
.logging_threshold = CRITERION_IMPORTANT,
.output_provider = &normal_logging,
.logger = &normal_logging,
.measure_time = true,
};

View file

@ -26,9 +26,7 @@
#include <stdlib.h>
#include <string.h>
#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"

View file

@ -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,