diff --git a/cpu/arm_common/syscalls.c b/cpu/arm_common/syscalls.c index 9441ddc693290105814c41e23f9600a07604e89c..068c0021ac5b57781021a3ce3d86f08a270044cb 100644 --- a/cpu/arm_common/syscalls.c +++ b/cpu/arm_common/syscalls.c @@ -67,10 +67,6 @@ extern uintptr_t __heap3_max; ///< maximum for end of heap memory space /*-----------------------------------------------------------------------------------*/ void __assert_func(const char *file, int line, const char *func, const char *failedexpr) { -#if SYSLOG_CONF_ASSERT - trace_number(TRACELOG_EV_ASSERTION, line); - syslog(SL_EMERGENCY, "assert", "%s() in %s:%u\n", func, file, line); -#endif printf("#!assertion %s failed\n\t%s() in %s:%u\n", failedexpr, func, file, line); _exit(3); } diff --git a/sys/Makefile b/sys/Makefile index 6d6f0ecad700cc1791a777f0b574843fa1487de1..cc16286e60e3b434a4b9acbfab685c8bf4b225c2 100644 --- a/sys/Makefile +++ b/sys/Makefile @@ -25,9 +25,6 @@ endif ifneq (,$(findstring sync_read,$(USEMODULE))) DIRS += sync_read endif -ifneq (,$(findstring syslog,$(USEMODULE))) - DIRS += syslog -endif ifneq (,$(findstring sysmon,$(USEMODULE))) DIRS += sysmon endif diff --git a/sys/syslog/Makefile b/sys/syslog/Makefile deleted file mode 100644 index 54d7db9bcd8d95726c54120cfdaf5b232cb5f7af..0000000000000000000000000000000000000000 --- a/sys/syslog/Makefile +++ /dev/null @@ -1,6 +0,0 @@ -INCLUDES = -I../include -I../drivers/include -I../lib -I$(RIOTCPU)/$(CPU)/include -I../net -I../../core/include -MODULE =syslog - -include $(MAKEBASE)/Makefile.base - - diff --git a/sys/syslog/syslog-api.c b/sys/syslog/syslog-api.c deleted file mode 100644 index 0ff92971cde3b00b65fecee4f10cc1bed8525590..0000000000000000000000000000000000000000 --- a/sys/syslog/syslog-api.c +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Syslog daemon - * - * Copyright (C) 2009-2013 Freie Universitaet Berlin - * - * This file subject to the terms and conditions of the GNU Lesser General - * Public License. See the file LICENSE in the top level directory for more - * details. - * - * @ingroup syslog - * @{ - * @file syslog-api.c - * @author Freie Universitaet Berlin - * @} - */ - -*******************************************************************************/ - -#include <stdarg.h> -#include "syslog.h" -#include "tracelog.h" - -#undef VSYSLOG -#define VSYSLOG(level, strModule, strFmt, argp) vsyslog(level, strModule, strFmt, argp) - -void -syslog(const uint8_t level, const char(*const strModule), const char *strFmt, ...) -{ - va_list argp; - - va_start(argp, strFmt); - VSYSLOG(level, strModule, strFmt, argp); - va_end(argp); -} -/*-----------------------------------------------------------------------------------*/ -#if (SYSLOG_CONF_LEVEL & SL_EMERGENCY) == SL_EMERGENCY -void syslog_emergency(const char(*const mod), const char *strFmt, ...) -{ - va_list argp; - - va_start(argp, strFmt); - VSYSLOG(SL_EMERGENCY, mod, strFmt, argp); - va_end(argp); -} -#endif -/*-----------------------------------------------------------------------------------*/ -#if (SYSLOG_CONF_LEVEL & SL_CRITICAL) == SL_CRITICAL -void syslog_critical(const char(*const mod), const char *strFmt, ...) -{ - va_list argp; - - va_start(argp, strFmt); - VSYSLOG(SL_CRITICAL, mod, strFmt, argp); - va_end(argp); -} -#endif -/*-----------------------------------------------------------------------------------*/ -#if (SYSLOG_CONF_LEVEL & SL_WARN) == SL_WARN -void syslog_warn(const char(*const mod), const char *strFmt, ...) -{ - va_list argp; - - va_start(argp, strFmt); - VSYSLOG(SL_WARN, mod, strFmt, argp); - va_end(argp); -} -#endif -/*-----------------------------------------------------------------------------------*/ -#if (SYSLOG_CONF_LEVEL & SL_NOTICE) == SL_NOTICE -void syslog_notice(const char(*const mod), const char *strFmt, ...) -{ - va_list argp; - - va_start(argp, strFmt); - VSYSLOG(SL_NOTICE, mod, strFmt, argp); - va_end(argp); -} -#endif -/*-----------------------------------------------------------------------------------*/ -#if (SYSLOG_CONF_LEVEL & SL_INFO) == SL_INFO -void syslog_info(const char(*const mod), const char *strFmt, ...) -{ - va_list argp; - - va_start(argp, strFmt); - VSYSLOG(SL_INFO, mod, strFmt, argp); - va_end(argp); -} -#endif -/*-----------------------------------------------------------------------------------*/ -#if SYSLOG_ISLEVEL(SL_DEBUG) -void syslog_debug(const char(*const mod), const char *strFmt, ...) -{ - va_list argp; - - va_start(argp, strFmt); - VSYSLOG(SL_DEBUG, mod, strFmt, argp); - va_end(argp); -} -#endif - diff --git a/sys/syslog/syslog-out.c b/sys/syslog/syslog-out.c deleted file mode 100644 index c353c591a4641c7306aba245e794d7c34d738a05..0000000000000000000000000000000000000000 --- a/sys/syslog/syslog-out.c +++ /dev/null @@ -1,188 +0,0 @@ -/****************************************************************************** -Copyright 2008-2009, Freie Universitaet Berlin (FUB). All rights reserved. - -These sources were developed at the Freie Universitaet Berlin, Computer Systems -and Telematics group (http://cst.mi.fu-berlin.de). -------------------------------------------------------------------------------- -This file is part of RIOT. - -This program is free software: you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -RIOT is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program. If not, see http://www.gnu.org/licenses/ . --------------------------------------------------------------------------------- -For further information and questions please use the web site - http://scatterweb.mi.fu-berlin.de -and the mailinglist (subscription via web site) - scatterweb@lists.spline.inf.fu-berlin.de -*******************************************************************************/ - -/** - * @file - * @ingroup syslog - * @brief System Logging Service output implementation - * - * @author Freie Universität Berlin, Computer Systems & Telematics - * @version $Revision: 3854 $ - * - * @note $Id: syslog-out.c 3854 2011-12-06 15:27:01Z hwill $ - */ - -#include <stdio.h> -#include <string.h> -#ifdef MODULE_FAT -#include <unistd.h> -#include <fcntl.h> -#include <sys/errno.h> -#endif -// sys -#include "cfg-feuerware.h" -#include "syslog.h" -#include "clock.h" -#include "device-rs232.h" -#if FEUERWARE_CONF_CORE_SUPPORTS_TIME -#include "timelib.h" -#endif -// net -#include "net-types.h" -#ifdef MODULE_TRACELOG -#include "tracelog.h" -#endif - -/*-----------------------------------------------------------------------------------*/ -void syslog_format_ascii(struct syslog_args *args, struct syslog_chainlink *chainlink) -{ - char buffer[SYSLOG_CONF_BUFSIZE + 25]; - int msglen = 0; - - if (args->message[0] != '\t') { - const char *strlevel = syslog_leveltostring(args->level); - msglen = snprintf(buffer, SYSLOG_CONF_BUFSIZE + 23, - "#[%u.%u:%u=%s] %s:", - NETWORK_ADDR_NET(NET_LOCAL_ADDRESS), NETWORK_ADDR_HOST(NET_LOCAL_ADDRESS), - args->level, strlevel, args->module - ); - } - - msglen += snprintf(buffer + msglen, SYSLOG_CONF_BUFSIZE + 23 - msglen, "%s", args->message); - buffer[msglen++] = '\n'; - buffer[msglen] = '\0'; - - args->message = buffer; - - if (chainlink != NULL && chainlink->fpout != NULL) { - chainlink->fpout(args, chainlink->next); - } -} -/*-----------------------------------------------------------------------------------*/ -void syslog_format_xml(struct syslog_args *args, struct syslog_chainlink *chainlink) -{ - const size_t bufsize = SYSLOG_CONF_BUFSIZE + 80; - char buffer[bufsize]; - char tbuf[20]; - int msglen = 0; - -#if FEUERWARE_CONF_CORE_SUPPORTS_TIME - time_get_string(tbuf, sizeof(tbuf)); -#else - sprintf(tbuf, "%lu", clock_time(NULL)); -#endif - - msglen = snprintf(buffer, bufsize, - "<log lvl=%u src=\"%u.%u\" id=%u ts=\"%s\" mod=\"%s\">%s</log>\n", - args->level, NETWORK_ADDR_NET(NET_LOCAL_ADDRESS), NETWORK_ADDR_HOST(NET_LOCAL_ADDRESS), - args->msgnum, tbuf, args->module, args->message - ); - - args->message = buffer; - - if (chainlink != NULL && chainlink->fpout != NULL) { - chainlink->fpout(args, chainlink->next); - } -} -/*-----------------------------------------------------------------------------------*/ -void syslog_copy_stdout(struct syslog_args *args, struct syslog_chainlink *chainlink) -{ - if (args->message[0] != '\t') { - const char *strlevel = syslog_leveltostring(args->level); - printf("#[%u.%u:%u=%s] %s:", - NETWORK_ADDR_NET(NET_LOCAL_ADDRESS), NETWORK_ADDR_HOST(NET_LOCAL_ADDRESS), - args->level, strlevel, args->module - ); - } - - printf("%s\n", args->message); - - if (chainlink != NULL && chainlink->fpout != NULL) { - chainlink->fpout(args, chainlink->next); - } -} -/*-----------------------------------------------------------------------------------*/ -void syslog_out_stdout(struct syslog_args *args, struct syslog_chainlink *chainlink) -{ - printf(args->message); - - if (chainlink != NULL && chainlink->fpout != NULL) { - chainlink->fpout(args, chainlink->next); - } -} -/*-----------------------------------------------------------------------------------*/ -#ifdef MODULE_FAT -static int syslog_file = -1; - -static int fat_open_logfile(const char *path); -static int fat_open_logfile(const char *path) -{ - char t[20]; - int file; - - file = open(path, O_WRONLY | O_APPEND | O_CREAT); - - time_get_string(t, sizeof(t)); - - if (file >= 0) { - syslog_notice("sys", "%s log %s opened", t, path); - } - else { - syslog_warn("sys", "%s log %s failed", t, path); - } - - return file; -} - -void syslog_out_file(struct syslog_args *args, struct syslog_chainlink *chainlink) -{ - if (syslog_file >= 0) { - size_t length = (size_t)strlen(args->message); - int ret = write(syslog_file, args->message, length); - - if (ret == 1) { -#ifdef MODULE_TRACELOG - trace_string(TRACELOG_EV_MEMORY, "fat"); -#endif - } - } - - if (chainlink != NULL && chainlink->fpout != NULL) { - chainlink->fpout(args, chainlink->next); - } -} - -bool syslog_open_file(void) -{ - syslog_file = fat_open_logfile("SYSLOG.LOG"); - return (syslog_file >= 0); -} -void syslog_close_file(void) -{ - close(syslog_file); - syslog_file = -1; -} -#endif diff --git a/sys/syslog/syslog.c b/sys/syslog/syslog.c deleted file mode 100644 index 18668da0d1a49eb778c1ac15132946bbc95093aa..0000000000000000000000000000000000000000 --- a/sys/syslog/syslog.c +++ /dev/null @@ -1,269 +0,0 @@ -/****************************************************************************** -Copyright 2008-2009, Freie Universitaet Berlin (FUB). All rights reserved. - -These sources were developed at the Freie Universitaet Berlin, Computer Systems -and Telematics group (http://cst.mi.fu-berlin.de). -------------------------------------------------------------------------------- -This file is part of RIOT. - -This program is free software: you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -RIOT is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program. If not, see http://www.gnu.org/licenses/ . --------------------------------------------------------------------------------- -For further information and questions please use the web site - http://scatterweb.mi.fu-berlin.de -and the mailinglist (subscription via web site) - scatterweb@lists.spline.inf.fu-berlin.de -*******************************************************************************/ - -/** - * @addtogroup syslog - * @{ - */ - -/** - * @file - * @brief System Logging Service implementation - * - * @author Freie Universität Berlin, Computer Systems & Telematics - * @author Michael Baar <baar@inf.fu-berlin.de> - * @version $Revision: 3854 $ - * - * @note $Id: syslog.c 3854 2011-12-06 15:27:01Z hwill $ - */ - -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "cfg-feuerware.h" -#include "cmdengine.h" -#include "device-rs232.h" -#include "syslog.h" -#include "sysmon.h" -#include "tracelog.h" - -static const char *syslog_level_stringtable = "emergency\0" - "critical\0" - "warn\0" - "notice\0" - "info\0" - "debug\0" - "\3"; - -__attribute__((section(".noinit"))) -static volatile unsigned int syslog_msgnum; - -static unsigned short syslog_flagtolevel(const uint8_t level); -static int find_interface_index_for_name(const char *name); - -extern struct syslog_interface syslog_interfaces[]; - -/*-----------------------------------------------------------------------------------*/ -void syslog_init(void) -{ - if (sysmon_initial_boot()) { - syslog_msgnum = 0; - } -} -/*-----------------------------------------------------------------------------------*/ -static bool testlevel(uint8_t filter_level, const uint8_t level) -{ - return ((filter_level & level) != 0); -} -/*-----------------------------------------------------------------------------------*/ -void vsyslog(const uint8_t level, const char(*const strModule), - const char *strFmt, va_list argp) -{ - int i; - struct syslog_interface *slif; // syslog interface - struct syslog_args args; // output function arguments - char message[SYSLOG_CONF_BUFSIZE]; // message buffer - int msglen = 0; - - args.message = NULL; - - /* check each syslog interface */ - for (i = 0; i < SYSLOG_CONF_NUM_INTERFACES; i++) { - slif = &syslog_interfaces[i]; - - /* run interface filter */ - if (slif->name != NULL && testlevel(cfg_feuerware.level[i], level)) { - /* filter matched, produce output */ - if (args.message == NULL) { - /* initialize structure one time, when actually needed */ - args.msgnum = syslog_msgnum++; - args.level = syslog_flagtolevel(level); - args.module = strModule; - args.message = message; - msglen = vsnprintf(message, SYSLOG_CONF_BUFSIZE - 1, strFmt, argp); - } - - args.interface = (const struct syslog_interface *)slif; - - /* invoke first link of ouput chain */ - if (slif->chain->fpout != NULL) { - slif->chain->fpout(&args, slif->chain->next); - } - } - } -} -/*-----------------------------------------------------------------------------------*/ -void syslog_printlevel(char *buffer, size_t bufsize, uint8_t level) -{ - uint8_t l = level; - int intlevel; - int bufpos; - int len = 0; - - bufpos = snprintf(buffer, bufsize, "%#.2x=", level); - bufsize -= bufpos; - - for (intlevel = 0; intlevel < SYSLOG_LEVELS_COUNT; intlevel++) { - if (l & 0x0001) { - const char *string = string_table_get(syslog_level_stringtable, intlevel); - - if (string) { - if (bufsize < 0) { - bufsize = 0; - } - - len = snprintf(&buffer[bufpos], bufsize, "%s%s", ((len > 0) ? "|" : ""), (char *)string); - bufsize -= len; - bufpos += len; - } - } - - l >>= 1; - } -} -/*-----------------------------------------------------------------------------------*/ -uint8_t syslog_set_level(const char *name, uint8_t level) -{ - uint8_t result; - int index = find_interface_index_for_name(name); - - if (index < 0) { - return 0; - } - - result = cfg_feuerware.level[index]; - cfg_feuerware.level[index] = level; - cfg_feuerware_spec.state->modified = 1; - - return result; -} -/*-----------------------------------------------------------------------------------*/ -const char *syslog_leveltostring(unsigned int level) -{ - return string_table_get(syslog_level_stringtable, level); -} -/*-----------------------------------------------------------------------------------*/ - -#if CMD_ISLEVEL(CMD_LEVEL_HUMAN_USER) -/** - * @brief Syslog-level property: <code>syslog [interface] [newlevel]</code> - * @ingroup commands - * @param[in] interface Name of the syslog interface to change (optional) - * @param[in] newlevel New loglevel value (see uint8_t) - * @return Current level - * - * \p Returns and optionally sets the syslog log-level. For available combinations see - * uint8_t. - * - * \p Usage: - * \li \c syslog Prints syslog configuration - * \li \c syslog \c 0x3f Sets loglevel of syslog node 0 (usually stdout) to 0x3f - * \li \c syslog \c stdout \c 0x3f Sets loglevel of syslog node "stdout" to 0x3f - */ -ASCCMD(syslog, 0, "[interface] [byte val]: syslog-level property"); -CMD_FUNCTION(syslog, cmdargs) -{ - int i; - - if (cmdargs->arg_size > 0) { - unsigned int argc; - const char *arg; - const char *name = NULL; - unsigned int value; - - argc = cmd_split_arguments(cmdargs->args); - arg = cmdargs->args; - - if (*arg >= 'A') { - // first argument is a string - name = arg; - // move to next argument - arg = cmd_get_next_argument(arg); - } - - if (*arg == '\0') { - return CMD_ERROR; - } - - value = strtoul(arg, NULL, 0); - syslog_set_level(name, value); - } - - for (i = 0; i < SYSLOG_CONF_NUM_INTERFACES; i++) { - if (syslog_interfaces[i].name != NULL) { - char buf[SYSLOG_PRINTLEVEL_MAXLEN]; - syslog_printlevel(buf, sizeof(buf), cfg_feuerware.level[i]); - cmdargs->fresponse(cmdargs, - CMD_RESPONSE_MULTILINE, - "%s:%s", - syslog_interfaces[i].name, - buf - ); - } - } - - return CMD_SUCCESS; -} -#endif -/*-----------------------------------------------------------------------------------*/ -/** - * @brief Convert bit flag to bit number - */ -static unsigned short syslog_flagtolevel(const uint8_t level) -{ - uint8_t l = level; - unsigned short intlevel; - - for (intlevel = 0; intlevel < SYSLOG_LEVELS_COUNT; intlevel++) { - if ((l & 1) == 1) { - break; - } - - l >>= 1; - } - - return intlevel; -} -/*-----------------------------------------------------------------------------------*/ -/** - * @brief Find an interface for a given name - */ -static int find_interface_index_for_name(const char *name) -{ - int i; - - for (i = 0; i < SYSLOG_CONF_NUM_INTERFACES; i++) { - if (strcmp(syslog_interfaces[i].name, name) == 0) { - return i; - } - } - - return -1; -} - -/** @} */