mirror of
https://github.com/cesanta/mongoose.git
synced 2024-11-26 12:08:59 +08:00
Writing mongoose errors to stdout
This commit is contained in:
parent
4a5e1ecf92
commit
5f4deeda06
14
main.c
14
main.c
@ -216,6 +216,14 @@ static void init_server_name(void) {
|
|||||||
mg_version());
|
mg_version());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *mongoose_callback(enum mg_event ev, struct mg_connection *conn) {
|
||||||
|
if (ev == MG_EVENT_LOG) {
|
||||||
|
printf("%s\n", mg_get_request_info(conn)->log_message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static void start_mongoose(int argc, char *argv[]) {
|
static void start_mongoose(int argc, char *argv[]) {
|
||||||
char *options[MAX_OPTIONS];
|
char *options[MAX_OPTIONS];
|
||||||
int i;
|
int i;
|
||||||
@ -242,15 +250,13 @@ static void start_mongoose(int argc, char *argv[]) {
|
|||||||
signal(SIGINT, signal_handler);
|
signal(SIGINT, signal_handler);
|
||||||
|
|
||||||
/* Start Mongoose */
|
/* Start Mongoose */
|
||||||
ctx = mg_start(NULL, NULL, (const char **) options);
|
ctx = mg_start(&mongoose_callback, NULL, (const char **) options);
|
||||||
for (i = 0; options[i] != NULL; i++) {
|
for (i = 0; options[i] != NULL; i++) {
|
||||||
free(options[i]);
|
free(options[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx == NULL) {
|
if (ctx == NULL) {
|
||||||
die("%s", "Failed to start Mongoose. Maybe some options are "
|
die("%s", "Failed to start Mongoose.");
|
||||||
"assigned bad values?\nTry to run with '-e error_log.txt' "
|
|
||||||
"and check error_log.txt for more information.");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user