mirror of
https://github.com/skeeto/endlessh.git
synced 2024-10-05 09:02:00 +02:00
Add LogLevel to the configuration file
This commit is contained in:
parent
6199d648f5
commit
20ec77e6ef
@ -55,4 +55,5 @@ Port 22
|
|||||||
Delay 30000
|
Delay 30000
|
||||||
MaxLineLength 8
|
MaxLineLength 8
|
||||||
MaxClients 512
|
MaxClients 512
|
||||||
|
LogLevel 1
|
||||||
```
|
```
|
||||||
|
14
endlessh.c
14
endlessh.c
@ -351,6 +351,7 @@ enum config_key {
|
|||||||
KEY_DELAY,
|
KEY_DELAY,
|
||||||
KEY_MAX_LINE_LENGTH,
|
KEY_MAX_LINE_LENGTH,
|
||||||
KEY_MAX_CLIENTS,
|
KEY_MAX_CLIENTS,
|
||||||
|
KEY_LOG_LEVEL,
|
||||||
};
|
};
|
||||||
|
|
||||||
static enum config_key
|
static enum config_key
|
||||||
@ -361,6 +362,7 @@ config_key_parse(const char *tok)
|
|||||||
[KEY_DELAY] = "Delay",
|
[KEY_DELAY] = "Delay",
|
||||||
[KEY_MAX_LINE_LENGTH] = "MaxLineLength",
|
[KEY_MAX_LINE_LENGTH] = "MaxLineLength",
|
||||||
[KEY_MAX_CLIENTS] = "MaxClients",
|
[KEY_MAX_CLIENTS] = "MaxClients",
|
||||||
|
[KEY_LOG_LEVEL] = "LogLevel",
|
||||||
};
|
};
|
||||||
for (size_t i = 1; i < sizeof(table) / sizeof(*table); i++)
|
for (size_t i = 1; i < sizeof(table) / sizeof(*table); i++)
|
||||||
if (!strcmp(tok, table[i]))
|
if (!strcmp(tok, table[i]))
|
||||||
@ -428,6 +430,18 @@ config_load(struct config *c, const char *file, int hardfail)
|
|||||||
case KEY_MAX_CLIENTS:
|
case KEY_MAX_CLIENTS:
|
||||||
config_set_max_line_length(c, tokens[1], hardfail);
|
config_set_max_line_length(c, tokens[1], hardfail);
|
||||||
break;
|
break;
|
||||||
|
case KEY_LOG_LEVEL: {
|
||||||
|
errno = 0;
|
||||||
|
char *end;
|
||||||
|
long v = strtol(tokens[1], &end, 10);
|
||||||
|
if (errno || *end || v < LOG_NONE || v > LOG_DEBUG) {
|
||||||
|
fprintf(stderr, "%s:%ld: Invalid log level '%s'\n",
|
||||||
|
file, lineno, tokens[1]);
|
||||||
|
if (hardfail) exit(EXIT_FAILURE);
|
||||||
|
} else {
|
||||||
|
loglevel = v;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user