drivers/syslog: syslog_initialize initialize dev/syslog too and call syslog to add the prefix and timestamp
This commit is contained in:
parent
f579c43754
commit
7828dff2ea
@ -187,6 +187,24 @@ int syslog_dev_channel(void);
|
|||||||
int syslog_console_channel(void);
|
int syslog_console_channel(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: syslog_register
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Register a simple character driver at /dev/syslog whose write() method
|
||||||
|
* will transfer data to the SYSLOG device. This can be useful if, for
|
||||||
|
* example, you want to redirect the output of a program to the SYSLOG.
|
||||||
|
*
|
||||||
|
* NOTE that unlike other syslog output, this data is unformatted raw
|
||||||
|
* byte output with no time-stamping or any other SYSLOG features
|
||||||
|
* supported.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef CONFIG_SYSLOG_CHARDEV
|
||||||
|
void syslog_register(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: syslog_add_intbuffer
|
* Name: syslog_add_intbuffer
|
||||||
*
|
*
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/syslog/syslog.h>
|
#include <syslog.h>
|
||||||
|
|
||||||
#include "syslog.h"
|
#include "syslog.h"
|
||||||
|
|
||||||
@ -90,7 +90,8 @@ static const struct file_operations syslog_fops =
|
|||||||
static ssize_t syslog_chardev_write(FAR struct file *filep,
|
static ssize_t syslog_chardev_write(FAR struct file *filep,
|
||||||
FAR const char *buffer, size_t len)
|
FAR const char *buffer, size_t len)
|
||||||
{
|
{
|
||||||
return syslog_write(buffer, len);
|
syslog(LOG_INFO, "%.*s", (int)len, buffer);
|
||||||
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -109,6 +109,13 @@ int syslog_initialize(enum syslog_init_e phase)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_SYSLOG_CHARDEV
|
||||||
|
if (phase == SYSLOG_INIT_EARLY)
|
||||||
|
{
|
||||||
|
syslog_register();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,24 +277,6 @@ int syslog_flush(void);
|
|||||||
|
|
||||||
int nx_vsyslog(int priority, FAR const IPTR char *src, FAR va_list *ap);
|
int nx_vsyslog(int priority, FAR const IPTR char *src, FAR va_list *ap);
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: syslog_register
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Register a simple character driver at /dev/syslog whose write() method
|
|
||||||
* will transfer data to the SYSLOG device. This can be useful if, for
|
|
||||||
* example, you want to redirect the output of a program to the SYSLOG.
|
|
||||||
*
|
|
||||||
* NOTE that unlike other syslog output, this data is unformatted raw
|
|
||||||
* byte output with no time-stamping or any other SYSLOG features
|
|
||||||
* supported.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#ifdef CONFIG_SYSLOG_CHARDEV
|
|
||||||
void syslog_register(void);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user