mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-17 19:30:36 +00:00
Update mg_log_set_fn()
This commit is contained in:
1 parent
d76f86f7db
commit
f122bd5797
1 file changed
+4
-3
+4
-3
@@ -4039,16 +4039,17 @@ mg_hexdump(c->recv.buf, c->recv.len); // Hex dump incoming data
|
|||||||
### mg\_log\_set\_fn()
|
### mg\_log\_set\_fn()
|
||||||
|
|
||||||
```c
|
```c
|
||||||
void mg_log_set_fn(void (*logfunc)(unsigned char ch));
|
void mg_log_set_fn(mg_pfn_t logfunc, void *param);
|
||||||
```
|
```
|
||||||
|
|
||||||
Redirect logs to a custom function. Parameters:
|
Redirect logs to a custom function. Parameters:
|
||||||
- `logfunc` - a pointer to a function that logs a single character
|
- `logfunc` - a pointer to a function that logs a single character
|
||||||
|
- `param` - a parameter for a logging function
|
||||||
|
|
||||||
Usage example: redirecting logs to syslog.
|
Usage example: redirecting logs to syslog.
|
||||||
|
|
||||||
```c
|
```c
|
||||||
static void mylog(uint8_t ch) {
|
static void mylog(char ch, void *param) {
|
||||||
static char buf[256];
|
static char buf[256];
|
||||||
static size_t len;
|
static size_t len;
|
||||||
buf[len++] = ch;
|
buf[len++] = ch;
|
||||||
@@ -4058,7 +4059,7 @@ static void mylog(uint8_t ch) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
...
|
...
|
||||||
mg_log_set_fn(mylog);
|
mg_log_set_fn(mylog, NULL);
|
||||||
```
|
```
|
||||||
|
|
||||||
## Filesystem
|
## Filesystem
|
||||||
|
|||||||
Reference in new issue
Block a user