diff --git a/doc/configuration.txt b/doc/configuration.txt index 4883295a7..6c7d7470d 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -2328,6 +2328,25 @@ thread-groups since up to 64 threads per group may be configured. The maximum number of groups is configured at compile time and defaults to 16. See also "nbthread". +trace + This command configures one "trace" subsystem statement. Each of them can be + found in the management manual, and follow the exact same syntax. Only one + statement per line is permitted (i.e. if some long trace configurations using + semi-colons are to be imported, they must be placed one per line). Any output + that the "trace" command would produce will be emitted during the parsing + step of the section. Most of the time these will be errors and warnings, but + certain incomplete commands might list permissible choices. This command is + not meant for regular use, it will generally only be suggested by developers + along complex debugging sessions. For this reason it is internally marked as + experimental, meaning that "expose-experimental-directives" must appear on a + line before any "trace" statement. Note that these directives are parsed on + the fly, so referencing a ring buffer that is only declared further will not + work. For such use cases it is suggested to place another "global" section + with only the "trace" statements after the declaration of that ring. It is + important to keep in mind that depending on the trace level and details, + enabling traces can severely degrade the global performance. Please refer to + the management manual for the statements syntax. + uid Changes the process's user ID to . It is recommended that the user ID is dedicated to HAProxy or to a small set of similar daemons. HAProxy must diff --git a/src/trace.c b/src/trace.c index 243174ab0..9c0b3f205 100644 --- a/src/trace.c +++ b/src/trace.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -675,6 +676,28 @@ static int trace_parse_statement(char **args, const char **msg) } +/* parse a "trace" statement in the "global" section, returns 1 if a message is returned, otherwise zero */ +static int cfg_parse_trace(char **args, int section_type, struct proxy *curpx, + const struct proxy *defpx, const char *file, int line, + char **err) +{ + const char *msg; + int severity; + + severity = trace_parse_statement(args, &msg); + if (msg) { + if (severity >= LOG_NOTICE) + ha_notice("parsing [%s:%d] : '%s': %s\n", file, line, args[0], msg); + else if (severity >= LOG_WARNING) + ha_warning("parsing [%s:%d] : '%s': %s\n", file, line, args[0], msg); + else { + ha_alert("parsing [%s:%d] : '%s': %s\n", file, line, args[0], msg); + return -1; + } + } + return 0; +} + /* parse the command, returns 1 if a message is returned, otherwise zero */ static int cli_parse_trace(char **args, char *payload, struct appctx *appctx, void *private) { @@ -754,6 +777,13 @@ static struct cli_kw_list cli_kws = {{ },{ INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws); +static struct cfg_kw_list cfg_kws = {ILH, { + { CFG_GLOBAL, "trace", cfg_parse_trace, KWF_EXPERIMENTAL }, + { /* END */ }, +}}; + +INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); + /* * Local variables: * c-indent-level: 8