2016-06-19 17:12:33 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* drivers/syslog/syslog_initialize.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 Gregory Nutt. All rights reserved.
|
|
|
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
*
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in
|
|
|
|
* the documentation and/or other materials provided with the
|
|
|
|
* distribution.
|
|
|
|
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
|
|
* used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
|
|
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
|
|
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <nuttx/syslog/syslog.h>
|
|
|
|
|
|
|
|
#include "syslog.h"
|
|
|
|
|
2016-06-19 19:16:12 +02:00
|
|
|
#ifndef CONFIG_ARCH_SYSLOG
|
|
|
|
|
2016-06-19 17:12:33 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Name: syslog_initialize
|
|
|
|
*
|
|
|
|
* Description:
|
|
|
|
* One power up, the SYSLOG facility is non-existent or limited to very
|
2016-06-19 19:16:12 +02:00
|
|
|
* low-level output. This function is called later in the initialization
|
2016-06-19 17:12:33 +02:00
|
|
|
* sequence after full driver support has been initialized. It installs
|
|
|
|
* the configured SYSLOG drivers and enables full SYSLOGing capability.
|
|
|
|
*
|
2016-06-19 19:16:12 +02:00
|
|
|
* This function performs these basic operations:
|
|
|
|
*
|
|
|
|
* - Initialize the SYSLOG device
|
|
|
|
* - Call syslog_channel() to begin using that device.
|
|
|
|
*
|
|
|
|
* If CONFIG_ARCH_SYSLOG is selected, then the architecture-specifica
|
|
|
|
* logic will provide its own SYSLOG device initialize which must include
|
|
|
|
* as a minimum a call to syslog_channel() to use the device.
|
|
|
|
*
|
2016-06-19 17:12:33 +02:00
|
|
|
* Input Parameters:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Returned Value:
|
|
|
|
* Zero (OK) is returned on success; a negated errno value is returned on
|
|
|
|
* any failure.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
int syslog_initialize(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* Not much to this yet... more is coming */
|
|
|
|
|
2016-06-19 17:39:21 +02:00
|
|
|
#if defined(CONFIG_SYSLOG_CHAR)
|
2016-06-19 17:12:33 +02:00
|
|
|
/* Enable use of a character device as the SYSLOG device */
|
|
|
|
|
2016-06-19 21:03:20 +02:00
|
|
|
ret = syslog_dev_channel();
|
2016-06-19 17:39:21 +02:00
|
|
|
|
|
|
|
#elif defined(CONFIG_RAMLOG_SYSLOG)
|
|
|
|
/* Use the RAMLOG as the SYSLOG device */
|
|
|
|
|
2016-06-19 21:03:20 +02:00
|
|
|
ret = ramlog_syslog_channel();
|
|
|
|
|
|
|
|
#elif defined(CONFIG_DEV_CONSOLE)
|
|
|
|
/* Use the console device as the SYSLOG device */
|
|
|
|
|
|
|
|
ret = syslog_console_channel();
|
2016-06-19 17:41:35 +02:00
|
|
|
|
2016-06-19 17:12:33 +02:00
|
|
|
#else
|
|
|
|
/* Nothing needs to be done */
|
|
|
|
|
|
|
|
ret = 0;
|
2016-06-19 17:41:35 +02:00
|
|
|
|
2016-06-19 17:12:33 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
2016-06-19 19:16:12 +02:00
|
|
|
|
|
|
|
#endif /* CONFIG_ARCH_SYSLOG */
|