Re: [RFC] [RFC] Add new SYS_LOG_BACKEND_FN to sys_log

Nashif, Anas

Looks ok, I am fine with this.

Can you please put this into a JIRA story and if you have code already, submit it to gerrit.
You also need to submit a sample backend and testcases or samples to illustrate how this can be used.


-----Original Message-----
From: Havusha, Yossi [mailto:yossi.havusha(a)]
Sent: Thursday, October 27, 2016 4:44 AM
To: devel(a)
Subject: [devel] [RFC] [RFC] Add new SYS_LOG_BACKEND_FN to sys_log

[devel] [RFC] Add new SYS_LOG_BACKEND_FN to sys_log.h ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    Current system log implementation:
    . When using system log API (SYS_LOG_ERR(.), SYS_LOG_WRN(.),
      SYS_LOG_INF(.), SYS_LOG_DBG(.) ), each of the four SYS_LOG_X macros is
      calling the same macro - SYS_LOG_BACKEND_FN that should output the log
    . SYS_LOG_BACKEND_FN is mapped to printk or printf according to kconfig.

    . Have the ability to use various back ends to output the messages,
      i.e. different UART than the console, SPI, flash, FS, etc..
    . The users should use the log in asynchronous way (i.e. not wait to IO

    . Keep the same system log api.
    . Add the option to map SYS_LOG_BACKEND_FN to a new function hook
    . Users may register their own function to the hook function
    . Application developers may add various back ends, that will use their
      hook function to output the data to the required driver.
    . Multiple back ends at the same time can be also implemented at the same
      approach - the hook function will call all back ends

Code change suggestion
    At: /include/misc/sys_log.h
    /* setup the hook func */
    extern void (*_syslog_hook)(const char *fmt, ...);
    void _syslog_hook_install(void (*hook)(const char *, ...));
    /* decide print func */
    #define SYS_LOG_BACKEND_FN _syslog_hook
    #elif defined(CONFIG_STDOUT_CONSOLE)
    #include <stdio.h>
    #define SYS_LOG_BACKEND_FN printf
    #include <misc/printk.h>
    #define SYS_LOG_BACKEND_FN printk
    #endif /* CONFIG_STDOUT_CONSOLE */


A member of the Intel Corporation group of companies

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

Join to automatically receive all group messages.