drivers/syslog: Remove emergstream implementation and caller

since emergstream always call syslog_force, but syslog_force is designed
for the interrupt context, and then doesn't mean any emergency thing.
On the other hand, emergstream has other bad side effect:
1.Can't output to file or dev channel
2.Can't work well with the interrupt buffer

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao 2021-05-17 22:38:22 +08:00 committed by Alan Carvalho de Assis
parent f12de4f7d9
commit 5f7c98b6e1
4 changed files with 3 additions and 132 deletions

View File

@ -21,7 +21,7 @@
############################################################################
# Include SYSLOG Infrastructure
CSRCS += vsyslog.c syslog_stream.c syslog_emergstream.c syslog_channel.c
CSRCS += vsyslog.c syslog_stream.c syslog_channel.c
CSRCS += syslog_putc.c syslog_write.c syslog_force.c syslog_flush.c
ifeq ($(CONFIG_SYSLOG_INTBUFFER),y)

View File

@ -1,99 +0,0 @@
/****************************************************************************
* drivers/syslog/syslog_emergstream.c
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include <nuttx/syslog/syslog.h>
#include <nuttx/streams.h>
#include "syslog.h"
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: emergstream_putc
****************************************************************************/
static void emergstream_putc(FAR struct lib_outstream_s *this, int ch)
{
int ret;
/* Try writing until the write was successful or until an irrecoverable
* error occurs.
*/
do
{
/* Write the character to the supported logging device. On failure,
* syslog_force returns a negated errno value.
*/
ret = syslog_force(ch);
if (ret >= 0)
{
this->nput++;
return;
}
/* The special return value -EINTR means that syslog_force() was
* awakened by a signal. This is not a real error and must be
* ignored in this context.
*/
}
while (ret == -EINTR);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: emergstream
*
* Description:
* Initializes a stream for use with the configured emergency syslog
* interface. Only accessible from with the OS SYSLOG logic.
*
* Input Parameters:
* stream - User allocated, uninitialized instance of struct
* lib_outstream_s to be initialized.
*
* Returned Value:
* None (User allocated instance initialized).
*
****************************************************************************/
void emergstream(FAR struct lib_outstream_s *stream)
{
stream->put = emergstream_putc;
stream->flush = lib_noflush;
stream->nput = 0;
}

View File

@ -116,22 +116,10 @@ int nx_vsyslog(int priority, FAR const IPTR char *fmt, FAR va_list *ap)
#endif
/* Wrap the low-level output in a stream object and let lib_vsprintf
* do the work. NOTE that emergency priority output is handled
* differently.. it will use the SYSLOG emergency stream.
* do the work.
*/
if (priority == LOG_EMERG)
{
/* Use the SYSLOG emergency stream */
emergstream(&stream.public);
}
else
{
/* Use the normal SYSLOG stream */
syslogstream_create(&stream);
}
syslogstream_create(&stream);
#if defined(CONFIG_SYSLOG_TIMESTAMP)
/* Prepend the message with the current time, if available */

View File

@ -380,24 +380,6 @@ void syslogstream_destroy(FAR struct lib_syslogstream_s *stream);
# define syslogstream_destroy(s)
#endif
/****************************************************************************
* Name: emergstream
*
* Description:
* Initializes a stream for use with the configured emergency syslog
* interface. Only accessible from with the OS SYSLOG logic.
*
* Input Parameters:
* stream - User allocated, uninitialized instance of struct
* lib_outstream_s to be initialized.
*
* Returned Value:
* None (User allocated instance initialized).
*
****************************************************************************/
void emergstream(FAR struct lib_outstream_s *stream);
/****************************************************************************
* Name: lib_noflush
*