summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-10-08 09:44:15 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-10-08 09:44:15 -0600
commitab1282a14781ce3244908b0421b295b1ea65f26f (patch)
tree7ca3d474b1d41ca65d07978577147e49da205f5b
parentcc7f2b26e037d5790cc8751a2f7354e39513783c (diff)
downloadpx4-nuttx-ab1282a14781ce3244908b0421b295b1ea65f26f.tar.gz
px4-nuttx-ab1282a14781ce3244908b0421b295b1ea65f26f.tar.bz2
px4-nuttx-ab1282a14781ce3244908b0421b295b1ea65f26f.zip
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
-rw-r--r--nuttx/fs/driver/fs_syslog.c7
-rw-r--r--nuttx/include/debug.h8
-rw-r--r--nuttx/include/syslog.h8
-rw-r--r--nuttx/libc/libc.csv4
-rw-r--r--nuttx/libc/misc/lib_dbg.c8
-rw-r--r--nuttx/libc/misc/lib_dumpbuffer.c39
-rw-r--r--nuttx/libc/stdio/lib_lowsyslog.c6
-rw-r--r--nuttx/libc/stdio/lib_printf.c6
-rw-r--r--nuttx/libc/stdio/lib_syslog.c6
9 files changed, 39 insertions, 53 deletions
diff --git a/nuttx/fs/driver/fs_syslog.c b/nuttx/fs/driver/fs_syslog.c
index 93eaa1fc9..ef35fb548 100644
--- a/nuttx/fs/driver/fs_syslog.c
+++ b/nuttx/fs/driver/fs_syslog.c
@@ -360,9 +360,10 @@ int syslog_initialize(void)
* Description:
* This is the low-level system logging interface. The debugging/syslogging
* interfaces are syslog() and lowsyslog(). The difference is is that
- * the syslog() function writes to fd=1 (stdout) whereas lowsyslog() uses
- * a lower level interface that works from interrupt handlers. This
- * function is a a low-level interface used to implement lowsyslog().
+ * the syslog() function writes to syslogging device (usually fd=1, stdout)
+ * whereas lowsyslog() uses a lower level interface that works from
+ * interrupt handlers. This function is a a low-level interface used to
+ * implement lowsyslog().
*
****************************************************************************/
diff --git a/nuttx/include/debug.h b/nuttx/include/debug.h
index 7fd6bc497..74f50935a 100644
--- a/nuttx/include/debug.h
+++ b/nuttx/include/debug.h
@@ -104,22 +104,22 @@
#ifdef CONFIG_DEBUG
# 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
# define lldbg(format, ...) \
- lowsyslog(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
+ lowsyslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
# else
# define lldbg(x...)
# endif
# ifdef CONFIG_DEBUG_VERBOSE
# 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
# define llvdbg(format, ...) \
- lowsyslog(EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
+ lowsyslog(LOG_DEBUG, EXTRA_FMT format EXTRA_ARG, ##__VA_ARGS__)
# else
# define llvdbg(x...)
# endif
diff --git a/nuttx/include/syslog.h b/nuttx/include/syslog.h
index ab0e6073c..1773159a4 100644
--- a/nuttx/include/syslog.h
+++ b/nuttx/include/syslog.h
@@ -128,12 +128,12 @@ int setlogmask(int mask);
* following.
*/
-int syslog(FAR const char *format, ...);
-int vsyslog(const char *src, va_list ap);
+int syslog(int priority, FAR const char *format, ...);
+int vsyslog(int priority, FAR const char *src, va_list ap);
#ifdef CONFIG_ARCH_LOWPUTC /* Non-standard */
-int lowsyslog(FAR const char *format, ...);
-int lowvsyslog(FAR const char *src, va_list ap);
+int lowsyslog(int priority, FAR const char *format, ...);
+int lowvsyslog(int priority, FAR const char *src, va_list ap);
#endif
/* Enable or disable syslog output */
diff --git a/nuttx/libc/libc.csv b/nuttx/libc/libc.csv
index 9b7f7ebfb..e384e69f3 100644
--- a/nuttx/libc/libc.csv
+++ b/nuttx/libc/libc.csv
@@ -65,7 +65,7 @@
"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 *","..."
"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 *"
"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"
@@ -155,7 +155,7 @@
"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"
"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"
"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 *"
diff --git a/nuttx/libc/misc/lib_dbg.c b/nuttx/libc/misc/lib_dbg.c
index 921a4e24d..41d68ef8c 100644
--- a/nuttx/libc/misc/lib_dbg.c
+++ b/nuttx/libc/misc/lib_dbg.c
@@ -95,7 +95,7 @@ int dbg(const char *format, ...)
#endif
{
va_start(ap, format);
- ret = vsyslog(format, ap);
+ ret = vsyslog(LOG_DEBUG, format, ap);
va_end(ap);
}
@@ -114,7 +114,7 @@ int lldbg(const char *format, ...)
#endif
{
va_start(ap, format);
- ret = lowvsyslog(format, ap);
+ ret = lowvsyslog(LOG_DEBUG, format, ap);
va_end(ap);
}
@@ -134,7 +134,7 @@ int vdbg(const char *format, ...)
#endif
{
va_start(ap, format);
- ret = vsyslog(format, ap);
+ ret = vsyslog(LOG_DEBUG, format, ap);
va_end(ap);
}
@@ -153,7 +153,7 @@ int llvdbg(const char *format, ...)
#endif
{
va_start(ap, format);
- ret = lowvsyslog(format, ap);
+ ret = lowvsyslog(LOG_DEBUG, format, ap);
va_end(ap);
}
diff --git a/nuttx/libc/misc/lib_dumpbuffer.c b/nuttx/libc/misc/lib_dumpbuffer.c
index e05c0ea4d..23e7e617b 100644
--- a/nuttx/libc/misc/lib_dumpbuffer.c
+++ b/nuttx/libc/misc/lib_dumpbuffer.c
@@ -47,22 +47,6 @@
* 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
****************************************************************************/
@@ -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 j;
unsigned int k;
- message("%s (%p):\n", msg, buffer);
+ lowsyslog(LOG_INFO, "%s (%p):\n", msg, buffer);
for (i = 0; i < buflen; i += 32)
{
- message("%04x: ", i);
+ lowsyslog(LOG_INFO, "%04x: ", i);
for (j = 0; j < 32; j++)
{
k = i + j;
if (j == 16)
{
- message(" ");
+ lowsyslog(LOG_INFO, " ");
}
if (k < buflen)
{
- message("%02x", buffer[k]);
+ lowsyslog(LOG_INFO, "%02x", buffer[k]);
}
else
{
- message(" ");
+ lowsyslog(LOG_INFO, " ");
}
}
- message(" ");
+ lowsyslog(LOG_INFO, " ");
for (j = 0; j < 32; j++)
{
k = i + j;
if (j == 16)
{
- message(" ");
+ lowsyslog(LOG_INFO, " ");
}
if (k < buflen)
{
if (buffer[k] >= 0x20 && buffer[k] < 0x7f)
{
- message("%c", buffer[k]);
+ lowsyslog(LOG_INFO, "%c", buffer[k]);
}
else
{
- message(".");
+ lowsyslog(LOG_INFO, ".");
}
}
}
- message("\n");
+ lowsyslog(LOG_INFO, "\n");
}
}
diff --git a/nuttx/libc/stdio/lib_lowsyslog.c b/nuttx/libc/stdio/lib_lowsyslog.c
index 3ada77bf5..e35db0fae 100644
--- a/nuttx/libc/stdio/lib_lowsyslog.c
+++ b/nuttx/libc/stdio/lib_lowsyslog.c
@@ -49,7 +49,7 @@
#if !defined(CONFIG_BUILD_PROTECTED) || defined(__KERNEL__)
/****************************************************************************
- * Definitions
+ * Pre-processor Definitions
****************************************************************************/
/****************************************************************************
@@ -90,7 +90,7 @@
#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;
@@ -108,7 +108,7 @@ int lowvsyslog(FAR const char *fmt, va_list ap)
* Name: lowsyslog
****************************************************************************/
-int lowsyslog(FAR const char *fmt, ...)
+int lowsyslog(int priority, FAR const char *fmt, ...)
{
va_list ap;
int ret;
diff --git a/nuttx/libc/stdio/lib_printf.c b/nuttx/libc/stdio/lib_printf.c
index a4530daad..f9446ed71 100644
--- a/nuttx/libc/stdio/lib_printf.c
+++ b/nuttx/libc/stdio/lib_printf.c
@@ -1,7 +1,7 @@
/****************************************************************************
* 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>
*
* 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
ret = vfprintf(stdout, fmt, ap);
#elif CONFIG_NFILE_DESCRIPTORS > 0
- ret = vsyslog(fmt, ap);
+ ret = vsyslog(LOG_INFO, fmt, ap);
#elif defined(CONFIG_ARCH_LOWPUTC)
- ret = lowvsyslog(fmt, ap);
+ ret = lowvsyslog(LOG_INFO, fmt, ap);
#else
# ifdef CONFIG_CPP_HAVE_WARNING
# warning "printf has no data sink"
diff --git a/nuttx/libc/stdio/lib_syslog.c b/nuttx/libc/stdio/lib_syslog.c
index 5f0958262..97465d51b 100644
--- a/nuttx/libc/stdio/lib_syslog.c
+++ b/nuttx/libc/stdio/lib_syslog.c
@@ -1,7 +1,7 @@
/****************************************************************************
* 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>
*
* Redistribution and use in source and binary forms, with or without
@@ -91,7 +91,7 @@
* 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)
@@ -135,7 +135,7 @@ int vsyslog(FAR const char *fmt, va_list ap)
* Name: syslog
****************************************************************************/
-int syslog(FAR const char *fmt, ...)
+int syslog(int priority, FAR const char *fmt, ...)
{
va_list ap;
int ret;