mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-11-20 02:11:00 +01:00
BUG/MINOR: log-format: fix %o flag
The %o flag was not working at all.
This commit is contained in:
parent
b7ff6a3a36
commit
81f5117a24
@ -55,7 +55,7 @@ int parse_logformat_var_args(char *args, struct logformat_node *node);
|
|||||||
* Parse a variable '%varname' or '%{args}varname' in logformat
|
* Parse a variable '%varname' or '%{args}varname' in logformat
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int parse_logformat_var(char *str, size_t len, struct proxy *curproxy);
|
int parse_logformat_var(char *str, size_t len, struct proxy *curproxy, int *options);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* add to the logformat linked list
|
* add to the logformat linked list
|
||||||
|
|||||||
13
src/log.c
13
src/log.c
@ -182,7 +182,7 @@ int parse_logformat_var_args(char *args, struct logformat_node *node)
|
|||||||
* Parse a variable '%varname' or '%{args}varname' in logformat
|
* Parse a variable '%varname' or '%{args}varname' in logformat
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int parse_logformat_var(char *str, size_t len, struct proxy *curproxy)
|
int parse_logformat_var(char *str, size_t len, struct proxy *curproxy, int *defoptions)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
char *arg = NULL; // arguments
|
char *arg = NULL; // arguments
|
||||||
@ -190,7 +190,6 @@ int parse_logformat_var(char *str, size_t len, struct proxy *curproxy)
|
|||||||
char *name = NULL;
|
char *name = NULL;
|
||||||
struct logformat_node *node = NULL;
|
struct logformat_node *node = NULL;
|
||||||
char varname[255] = { 0 }; // variable name
|
char varname[255] = { 0 }; // variable name
|
||||||
int logformat_options = 0x00000000;
|
|
||||||
|
|
||||||
for (i = 1; i < len; i++) { // escape first char %
|
for (i = 1; i < len; i++) { // escape first char %
|
||||||
if (!arg && str[i] == '{') {
|
if (!arg && str[i] == '{') {
|
||||||
@ -210,11 +209,11 @@ int parse_logformat_var(char *str, size_t len, struct proxy *curproxy)
|
|||||||
if (!((logformat_keywords[j].mode == PR_MODE_HTTP) && (curproxy->mode == PR_MODE_TCP))) {
|
if (!((logformat_keywords[j].mode == PR_MODE_HTTP) && (curproxy->mode == PR_MODE_TCP))) {
|
||||||
node = calloc(1, sizeof(struct logformat_node));
|
node = calloc(1, sizeof(struct logformat_node));
|
||||||
node->type = logformat_keywords[j].type;
|
node->type = logformat_keywords[j].type;
|
||||||
node->options = logformat_options;
|
node->options = *defoptions;
|
||||||
node->arg = arg;
|
node->arg = arg;
|
||||||
parse_logformat_var_args(node->arg, node);
|
parse_logformat_var_args(node->arg, node);
|
||||||
if (node->type == LOG_GLOBAL) {
|
if (node->type == LOG_GLOBAL) {
|
||||||
logformat_options = node->options;
|
*defoptions = node->options;
|
||||||
free(node);
|
free(node);
|
||||||
} else {
|
} else {
|
||||||
if (logformat_keywords[j].config_callback != NULL) {
|
if (logformat_keywords[j].config_callback != NULL) {
|
||||||
@ -266,8 +265,6 @@ void add_to_logformat_list(char *start, char *end, int type, struct proxy *curpr
|
|||||||
node->arg = str;
|
node->arg = str;
|
||||||
node->type = LOG_TEXT; // type string
|
node->type = LOG_TEXT; // type string
|
||||||
LIST_ADDQ(&curproxy->logformat, &node->list);
|
LIST_ADDQ(&curproxy->logformat, &node->list);
|
||||||
} else if (type == LOG_VARIABLE) { /* type variable */
|
|
||||||
parse_logformat_var(start, end - start, curproxy);
|
|
||||||
} else if (type == LOG_SEPARATOR) {
|
} else if (type == LOG_SEPARATOR) {
|
||||||
struct logformat_node *node = calloc(1, sizeof(struct logformat_node));
|
struct logformat_node *node = calloc(1, sizeof(struct logformat_node));
|
||||||
node->type = LOG_SEPARATOR;
|
node->type = LOG_SEPARATOR;
|
||||||
@ -286,6 +283,7 @@ void parse_logformat_string(char *str, struct proxy *curproxy)
|
|||||||
int cformat = -1; /* current token format : LOG_TEXT, LOG_SEPARATOR, LOG_VARIABLE */
|
int cformat = -1; /* current token format : LOG_TEXT, LOG_SEPARATOR, LOG_VARIABLE */
|
||||||
int pformat = -1; /* previous token format */
|
int pformat = -1; /* previous token format */
|
||||||
struct logformat_node *tmplf, *back;
|
struct logformat_node *tmplf, *back;
|
||||||
|
int options = 0;
|
||||||
|
|
||||||
/* flush the list first. */
|
/* flush the list first. */
|
||||||
list_for_each_entry_safe(tmplf, back, &curproxy->logformat, list) {
|
list_for_each_entry_safe(tmplf, back, &curproxy->logformat, list) {
|
||||||
@ -303,6 +301,9 @@ void parse_logformat_string(char *str, struct proxy *curproxy)
|
|||||||
(pformat != LF_STARG && cformat != LF_VAR)) || *str == '\0') {
|
(pformat != LF_STARG && cformat != LF_VAR)) || *str == '\0') {
|
||||||
if (pformat > LF_VAR) // unfinished string
|
if (pformat > LF_VAR) // unfinished string
|
||||||
pformat = LF_TEXT;
|
pformat = LF_TEXT;
|
||||||
|
if (pformat == LF_VAR)
|
||||||
|
parse_logformat_var(sp, str - sp, curproxy, &options);
|
||||||
|
else
|
||||||
add_to_logformat_list(sp, str, pformat, curproxy);
|
add_to_logformat_list(sp, str, pformat, curproxy);
|
||||||
sp = str;
|
sp = str;
|
||||||
if (*str == '\0')
|
if (*str == '\0')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user