#include "lib_internal.h"
+#if defined(CONFIG_LOGM) && defined(CONFIG_PRINTF2LOGM)
+#include <tinyara/logm.h>
+#endif
+
/****************************************************************************
* Definitions
****************************************************************************/
va_start(ap, fmt);
#if defined(CONFIG_LOGM) && defined(CONFIG_PRINTF2LOGM)
- ret = logm_internal(LOGM_DEF_PRIORITY, fmt, ap);
+ ret = logm_internal(LOGM_NORMAL, LOGM_UNKNOWN, LOGM_DEF_PRIORITY, fmt, ap);
#elif CONFIG_NFILE_STREAMS > 0
ret = vfprintf(stdout, fmt, ap);
#elif CONFIG_NFILE_DESCRIPTORS > 0
#include <syslog.h>
#include <tinyara/streams.h>
+#if defined(CONFIG_LOGM) && defined(CONFIG_SYSLOG2LOGM)
#include <tinyara/logm.h>
-
+#endif
#include "syslog/syslog.h"
#if defined(CONFIG_ARCH_LOWPUTC) || defined(CONFIG_SYSLOG)
if ((g_syslog_mask & LOG_MASK(priority)) != 0) {
/* Yes.. let vsylog_internal to the deed */
#if defined(CONFIG_LOGM) && defined(CONFIG_SYSLOG2LOGM)
- ret = logm_internal(priority, fmt, ap);
+ ret = logm_internal(LOGM_LOWPUT, LOGM_UNKNOWN, priority, fmt, ap);
#else
ret = lowvsyslog_internal(fmt, ap);
#endif
#include <tinyara/clock.h>
#include <tinyara/streams.h>
+#if defined(CONFIG_LOGM) && defined(CONFIG_SYSLOG2LOGM)
#include <tinyara/logm.h>
-
+#endif
#include "syslog/syslog.h"
/****************************************************************************
if ((g_syslog_mask & LOG_MASK(priority)) != 0) {
/* Yes.. let vsylog_internal do the deed */
#if defined(CONFIG_LOGM) && defined(CONFIG_SYSLOG2LOGM)
- ret = logm_internal(priority, fmt, ap);
+ ret = logm_internal(LOGM_NORMAL, LOGM_UNKNOWN, priority, fmt, ap);
#else
ret = vsyslog_internal(fmt, ap);
#endif
#define LOGM_DEF_PRIORITY (7)
/* Log priority levels in logm */
-enum logm_loglevels_e {
+enum logm_loglevel_e {
LOGM_EMR, /* Emergency */
LOGM_ART, /* Alert */
LOGM_CRT, /* Critical */
/* This would grow later */
};
+/* Log flags for somethings related to logging */
+enum logm_logflag_e {
+ LOGM_NORMAL,
+ LOGM_LOWPUT
+};
+
+/* Log index means where messages are from */
+enum logm_logindex_e {
+ LOGM_UNKNOWN
+ /* Not supported yet. This would be updated later */
+};
+
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
#endif
void logm_start(void);
-int logm_internal(int priority, const char *fmt, va_list valst);
-int logm(int flag, int mod, int priority, const char *fmt, ...);
+int logm_internal(int flag, int indx, int priority, const char *fmt, va_list valst);
+int logm(int flag, int indx, int priority, const char *fmt, ...);
int logm_set_values(enum logm_param_type_e type, int value);
int logm_get_values(enum logm_param_type_e type, int* value);
outstream->nput = 0;
}
+#ifdef CONFIG_ARCH_LOWPUTC
+static void logm_flush(struct lib_outstream_s *stream)
+{
+ sched_lock();
+
+ while (g_logm_head != g_logm_tail) {
+ stream->put(stream, g_logm_rsvbuf[g_logm_head]);
+ g_logm_head = (g_logm_head + 1) % logm_bufsize;
+ }
+
+ if (LOGM_STATUS(LOGM_BUFFER_OVERFLOW)) {
+ LOGM_STATUS_CLEAR(LOGM_BUFFER_OVERFLOW);
+ }
+
+ /* Reset nput in stream for next stream */
+ stream->nput = 0;
+
+ sched_unlock();
+}
+#endif
+
/* logm_internal hook for syslog & printfs */
-int logm_internal(int priority, const char *fmt, va_list ap)
+int logm_internal(int flag, int indx, int priority, const char *fmt, va_list ap)
{
irqstate_t flags;
int ret = 0;
struct timespec ts;
#endif
- if (LOGM_STATUS(LOGM_READY) && !LOGM_STATUS(LOGM_BUFFER_RESIZE_REQ) && !up_interrupt_context()) {
+ if (LOGM_STATUS(LOGM_READY) && !LOGM_STATUS(LOGM_BUFFER_RESIZE_REQ) \
+ && flag == LOGM_NORMAL && !up_interrupt_context()) {
+
flags = irqsave();
if (LOGM_STATUS(LOGM_BUFFER_OVERFLOW)) {
}
#endif
ret = lib_vsprintf(&strm, fmt, ap);
+
g_logm_tail = (g_logm_tail + ret) % logm_bufsize;
if ((g_logm_tail + 1) % logm_bufsize == g_logm_head) {
g_logm_dropmsg_count = 1;
g_logm_overflow_offset = g_logm_tail;
}
-
irqrestore(flags);
} else {
/* Low Output: Sytem is not yet completely ready or this is called from interrupt handler */
#ifdef CONFIG_ARCH_LOWPUTC
lib_lowoutstream(&strm);
+ logm_flush(&strm);
ret = lib_vsprintf(&strm, fmt, ap);
#endif
}
/* LOGIC for initial test here */
va_start(ap, fmt);
- ret = logm_internal(priority, fmt, ap);
+ ret = logm_internal(flag, indx, priority, fmt, ap);
va_end(ap);
return ret;