mirror of
https://github.com/apache/nuttx.git
synced 2026-06-07 17:33:08 +08:00
syslog: Add sc_write_force callback
It is used to write the log message to the channel immediately when the log message is generated in the interrupt context, which is faster than the normal force callback. Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
committed by
Alan Carvalho de Assis
parent
e62c915972
commit
efd1b838e6
@@ -57,31 +57,43 @@
|
||||
|
||||
static ssize_t syslog_default_write(FAR const char *buffer, size_t buflen)
|
||||
{
|
||||
int i;
|
||||
size_t nwritten = 0;
|
||||
int i;
|
||||
|
||||
if (up_interrupt_context() || sched_idletask())
|
||||
{
|
||||
for (nwritten = 0; nwritten < buflen; nwritten++)
|
||||
{
|
||||
#ifdef CONFIG_SYSLOG_INTBUFFER
|
||||
if (up_interrupt_context())
|
||||
if (up_interrupt_context())
|
||||
{
|
||||
for (nwritten = 0; nwritten < buflen; nwritten++)
|
||||
{
|
||||
syslog_add_intbuffer(buffer[nwritten]);
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
for (i = 0; i < CONFIG_SYSLOG_MAX_CHANNELS; i++)
|
||||
{
|
||||
for (i = 0; i < CONFIG_SYSLOG_MAX_CHANNELS; i++)
|
||||
{
|
||||
if (g_syslog_channel[i] == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
FAR struct syslog_channel_s *channel = g_syslog_channel[i];
|
||||
|
||||
DEBUGASSERT(g_syslog_channel[i]->sc_ops->sc_force != NULL);
|
||||
g_syslog_channel[i]->sc_ops->sc_force(g_syslog_channel[i],
|
||||
buffer[nwritten]);
|
||||
if (channel == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (channel->sc_ops->sc_write_force != NULL)
|
||||
{
|
||||
nwritten =
|
||||
channel->sc_ops->sc_write_force(channel, buffer, buflen);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUGASSERT(channel->sc_ops->sc_force != NULL);
|
||||
for (nwritten = 0; nwritten < buflen; nwritten++)
|
||||
{
|
||||
channel->sc_ops->sc_force(channel, buffer[nwritten]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,25 +102,23 @@ static ssize_t syslog_default_write(FAR const char *buffer, size_t buflen)
|
||||
{
|
||||
for (i = 0; i < CONFIG_SYSLOG_MAX_CHANNELS; i++)
|
||||
{
|
||||
if (g_syslog_channel[i] == NULL)
|
||||
FAR struct syslog_channel_s *channel = g_syslog_channel[i];
|
||||
|
||||
if (channel == NULL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (g_syslog_channel[i]->sc_ops->sc_write)
|
||||
if (channel->sc_ops->sc_write != NULL)
|
||||
{
|
||||
nwritten =
|
||||
g_syslog_channel[i]->sc_ops->sc_write(g_syslog_channel[i],
|
||||
buffer, buflen);
|
||||
nwritten = channel->sc_ops->sc_write(channel, buffer, buflen);
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUGASSERT(g_syslog_channel[i]->sc_ops->sc_putc != NULL);
|
||||
|
||||
DEBUGASSERT(channel->sc_ops->sc_putc != NULL);
|
||||
for (nwritten = 0; nwritten < buflen; nwritten++)
|
||||
{
|
||||
g_syslog_channel[i]->sc_ops->sc_putc(g_syslog_channel[i],
|
||||
buffer[nwritten]);
|
||||
channel->sc_ops->sc_putc(channel, buffer[nwritten]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user