mirror of
https://github.com/apache/nuttx.git
synced 2026-06-04 14:53:47 +08:00
make standard syslog and vsyslog POSIX compliant (also modify non-standard syslog functions for compatibility). This will break a lot of things until ALL usage of syslog is updated to use the modified interfaces
This commit is contained in:
@@ -360,9 +360,10 @@ int syslog_initialize(void)
|
|||||||
* Description:
|
* Description:
|
||||||
* This is the low-level system logging interface. The debugging/syslogging
|
* This is the low-level system logging interface. The debugging/syslogging
|
||||||
* interfaces are syslog() and lowsyslog(). The difference is is that
|
* interfaces are syslog() and lowsyslog(). The difference is is that
|
||||||
* the syslog() function writes to fd=1 (stdout) whereas lowsyslog() uses
|
* the syslog() function writes to syslogging device (usually fd=1, stdout)
|
||||||
* a lower level interface that works from interrupt handlers. This
|
* whereas lowsyslog() uses a lower level interface that works from
|
||||||
* function is a a low-level interface used to implement lowsyslog().
|
* interrupt handlers. This function is a a low-level interface used to
|
||||||
|
* implement lowsyslog().
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|||||||
+4
-4
@@ -104,22 +104,22 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_DEBUG
|
#ifdef CONFIG_DEBUG
|
||||||
# define dbg(format, ...) \
|
# define dbg(format, ...) \
|
||||||
syslog(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
|
syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
|
||||||
|
|
||||||
# ifdef CONFIG_ARCH_LOWPUTC
|
# ifdef CONFIG_ARCH_LOWPUTC
|
||||||
# define lldbg(format, ...) \
|
# define lldbg(format, ...) \
|
||||||
lowsyslog(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
|
lowsyslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
|
||||||
# else
|
# else
|
||||||
# define lldbg(x...)
|
# define lldbg(x...)
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
# ifdef CONFIG_DEBUG_VERBOSE
|
# ifdef CONFIG_DEBUG_VERBOSE
|
||||||
# define vdbg(format, ...) \
|
# define vdbg(format, ...) \
|
||||||
syslog(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
|
syslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
|
||||||
|
|
||||||
# ifdef CONFIG_ARCH_LOWPUTC
|
# ifdef CONFIG_ARCH_LOWPUTC
|
||||||
# define llvdbg(format, ...) \
|
# define llvdbg(format, ...) \
|
||||||
lowsyslog(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
|
lowsyslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
|
||||||
# else
|
# else
|
||||||
# define llvdbg(x...)
|
# define llvdbg(x...)
|
||||||
# endif
|
# endif
|
||||||
|
|||||||
+4
-4
@@ -128,12 +128,12 @@ int setlogmask(int mask);
|
|||||||
* following.
|
* following.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int syslog(FAR const char *format, ...);
|
int syslog(int priority, FAR const char *format, ...);
|
||||||
int vsyslog(const char *src, va_list ap);
|
int vsyslog(int priority, FAR const char *src, va_list ap);
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_LOWPUTC /* Non-standard */
|
#ifdef CONFIG_ARCH_LOWPUTC /* Non-standard */
|
||||||
int lowsyslog(FAR const char *format, ...);
|
int lowsyslog(int priority, FAR const char *format, ...);
|
||||||
int lowvsyslog(FAR const char *src, va_list ap);
|
int lowvsyslog(int priority, FAR const char *src, va_list ap);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Enable or disable syslog output */
|
/* Enable or disable syslog output */
|
||||||
|
|||||||
+2
-2
@@ -65,7 +65,7 @@
|
|||||||
"llabs","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","long long int","long long int"
|
"llabs","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","long long int","long long int"
|
||||||
"lldbg","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG) && defined(CONFIG_ARCH_LOWPUTC)","int","const char *","..."
|
"lldbg","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG) && defined(CONFIG_ARCH_LOWPUTC)","int","const char *","..."
|
||||||
"llvdbg","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_ARCH_LOWPUTC)","int","const char *","..."
|
"llvdbg","debug.h","!defined(CONFIG_CPP_HAVE_VARARGS) && defined(CONFIG_DEBUG) && defined(CONFIG_DEBUG_VERBOSE) && defined(CONFIG_ARCH_LOWPUTC)","int","const char *","..."
|
||||||
"lowsyslog","syslog.h","","int","FAR const char *","..."
|
"lowsyslog","syslog.h","","int","int","FAR const char *","..."
|
||||||
"match","nuttx/regex.h","","int","const char *","const char *"
|
"match","nuttx/regex.h","","int","const char *","const char *"
|
||||||
"memccpy","string.h","","FAR void","FAR void *","FAR const void *","int c","size_t"
|
"memccpy","string.h","","FAR void","FAR void *","FAR const void *","int c","size_t"
|
||||||
"memchr","string.h","","FAR void","FAR const void *","int c","size_t"
|
"memchr","string.h","","FAR void","FAR const void *","int c","size_t"
|
||||||
@@ -155,7 +155,7 @@
|
|||||||
"strtoll","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","long long","const char *nptr","char **endptr","int base"
|
"strtoll","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","long long","const char *nptr","char **endptr","int base"
|
||||||
"strtoul","stdlib.h","","unsigned long","const char *","char **","int"
|
"strtoul","stdlib.h","","unsigned long","const char *","char **","int"
|
||||||
"strtoull","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","unsigned long long","const char *","char **","int"
|
"strtoull","stdlib.h","defined(CONFIG_HAVE_LONG_LONG)","unsigned long long","const char *","char **","int"
|
||||||
"syslog","syslog.h","","int","FAR const char *","..."
|
"syslog","syslog.h","","int","int","FAR const char *","..."
|
||||||
"syslog_enable","syslog.h","defined(CONFIG_SYSLOG_ENABLE)","void","bool"
|
"syslog_enable","syslog.h","defined(CONFIG_SYSLOG_ENABLE)","void","bool"
|
||||||
"tcflush","termios.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","int","int"
|
"tcflush","termios.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","int","int"
|
||||||
"tcgetattr","termios.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","int","FAR struct termios *"
|
"tcgetattr","termios.h","CONFIG_NFILE_DESCRIPTORS > 0 && defined(CONFIG_SERIAL_TERMIOS)","int","int","FAR struct termios *"
|
||||||
|
|||||||
|
+4
-4
@@ -95,7 +95,7 @@ int dbg(const char *format, ...)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
ret = vsyslog(format, ap);
|
ret = vsyslog(LOG_DEBUG, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ int lldbg(const char *format, ...)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
ret = lowvsyslog(format, ap);
|
ret = lowvsyslog(LOG_DEBUG, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,7 +134,7 @@ int vdbg(const char *format, ...)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
ret = vsyslog(format, ap);
|
ret = vsyslog(LOG_DEBUG, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,7 +153,7 @@ int llvdbg(const char *format, ...)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
va_start(ap, format);
|
va_start(ap, format);
|
||||||
ret = lowvsyslog(format, ap);
|
ret = lowvsyslog(LOG_DEBUG, format, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+12
-27
@@ -47,22 +47,6 @@
|
|||||||
* Pre-processor definitions
|
* Pre-processor definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* Select the lowest level debug interface available */
|
|
||||||
|
|
||||||
#ifdef CONFIG_CPP_HAVE_VARARGS
|
|
||||||
# ifdef CONFIG_ARCH_LOWPUTC
|
|
||||||
# define message(format, ...) lowsyslog(format, ##__VA_ARGS__)
|
|
||||||
# else
|
|
||||||
# define message(format, ...) syslog(format, ##__VA_ARGS__)
|
|
||||||
# endif
|
|
||||||
#else
|
|
||||||
# ifdef CONFIG_ARCH_LOWPUTC
|
|
||||||
# define message lowsyslog
|
|
||||||
# else
|
|
||||||
# define message syslog
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -75,58 +59,59 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void lib_dumpbuffer(FAR const char *msg, FAR const uint8_t *buffer, unsigned int buflen)
|
void lib_dumpbuffer(FAR const char *msg, FAR const uint8_t *buffer,
|
||||||
|
unsigned int buflen)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
unsigned int k;
|
unsigned int k;
|
||||||
|
|
||||||
message("%s (%p):\n", msg, buffer);
|
lowsyslog(LOG_INFO, "%s (%p):\n", msg, buffer);
|
||||||
for (i = 0; i < buflen; i += 32)
|
for (i = 0; i < buflen; i += 32)
|
||||||
{
|
{
|
||||||
message("%04x: ", i);
|
lowsyslog(LOG_INFO, "%04x: ", i);
|
||||||
for (j = 0; j < 32; j++)
|
for (j = 0; j < 32; j++)
|
||||||
{
|
{
|
||||||
k = i + j;
|
k = i + j;
|
||||||
|
|
||||||
if (j == 16)
|
if (j == 16)
|
||||||
{
|
{
|
||||||
message(" ");
|
lowsyslog(LOG_INFO, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k < buflen)
|
if (k < buflen)
|
||||||
{
|
{
|
||||||
message("%02x", buffer[k]);
|
lowsyslog(LOG_INFO, "%02x", buffer[k]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
message(" ");
|
lowsyslog(LOG_INFO, " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message(" ");
|
lowsyslog(LOG_INFO, " ");
|
||||||
for (j = 0; j < 32; j++)
|
for (j = 0; j < 32; j++)
|
||||||
{
|
{
|
||||||
k = i + j;
|
k = i + j;
|
||||||
|
|
||||||
if (j == 16)
|
if (j == 16)
|
||||||
{
|
{
|
||||||
message(" ");
|
lowsyslog(LOG_INFO, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (k < buflen)
|
if (k < buflen)
|
||||||
{
|
{
|
||||||
if (buffer[k] >= 0x20 && buffer[k] < 0x7f)
|
if (buffer[k] >= 0x20 && buffer[k] < 0x7f)
|
||||||
{
|
{
|
||||||
message("%c", buffer[k]);
|
lowsyslog(LOG_INFO, "%c", buffer[k]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
message(".");
|
lowsyslog(LOG_INFO, ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
message("\n");
|
lowsyslog(LOG_INFO, "\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
#if !defined(CONFIG_BUILD_PROTECTED) || defined(__KERNEL__)
|
#if !defined(CONFIG_BUILD_PROTECTED) || defined(__KERNEL__)
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
|
|
||||||
#if defined(CONFIG_ARCH_LOWPUTC) || defined(CONFIG_SYSLOG)
|
#if defined(CONFIG_ARCH_LOWPUTC) || defined(CONFIG_SYSLOG)
|
||||||
|
|
||||||
int lowvsyslog(FAR const char *fmt, va_list ap)
|
int lowvsyslog(int priority, FAR const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
struct lib_outstream_s stream;
|
struct lib_outstream_s stream;
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ int lowvsyslog(FAR const char *fmt, va_list ap)
|
|||||||
* Name: lowsyslog
|
* Name: lowsyslog
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int lowsyslog(FAR const char *fmt, ...)
|
int lowsyslog(int priority, FAR const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int ret;
|
int ret;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* libc/stdio/lib_printf.c
|
* libc/stdio/lib_printf.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2008, 2011-2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2008, 2011-2012, 2014 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -95,9 +95,9 @@ int printf(FAR const char *fmt, ...)
|
|||||||
#if CONFIG_NFILE_STREAMS > 0
|
#if CONFIG_NFILE_STREAMS > 0
|
||||||
ret = vfprintf(stdout, fmt, ap);
|
ret = vfprintf(stdout, fmt, ap);
|
||||||
#elif CONFIG_NFILE_DESCRIPTORS > 0
|
#elif CONFIG_NFILE_DESCRIPTORS > 0
|
||||||
ret = vsyslog(fmt, ap);
|
ret = vsyslog(LOG_INFO, fmt, ap);
|
||||||
#elif defined(CONFIG_ARCH_LOWPUTC)
|
#elif defined(CONFIG_ARCH_LOWPUTC)
|
||||||
ret = lowvsyslog(fmt, ap);
|
ret = lowvsyslog(LOG_INFO, fmt, ap);
|
||||||
#else
|
#else
|
||||||
# ifdef CONFIG_CPP_HAVE_WARNING
|
# ifdef CONFIG_CPP_HAVE_WARNING
|
||||||
# warning "printf has no data sink"
|
# warning "printf has no data sink"
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* libc/stdio/lib_syslog.c
|
* libc/stdio/lib_syslog.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011-2014 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
* Name: vsyslog
|
* Name: vsyslog
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int vsyslog(FAR const char *fmt, va_list ap)
|
int vsyslog(int priority, FAR const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_SYSLOG)
|
#if defined(CONFIG_SYSLOG)
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ int vsyslog(FAR const char *fmt, va_list ap)
|
|||||||
* Name: syslog
|
* Name: syslog
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int syslog(FAR const char *fmt, ...)
|
int syslog(int priority, FAR const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
int ret;
|
int ret;
|
||||||
|
|||||||
Reference in New Issue
Block a user