Topics

[RFC] [RFC] Add new SYS_LOG_BACKEND_FN to sys_log


Havusha, Yossi <yossi.havusha@...>
 

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

========
Overview
========
    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
      message. 
    • SYS_LOG_BACKEND_FN is mapped to printk or printf according to kconfig.

=====
Goals
=====
    • 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
      drivers).

==========
Suggestion
==========
    • 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 */
    #if defined(CONFIG_LOGGER_EXTERNAL_HOOK)
    #define SYS_LOG_BACKEND_FN _syslog_hook
    #elif defined(CONFIG_STDOUT_CONSOLE)
    #include <stdio.h>
    #define SYS_LOG_BACKEND_FN printf
    #else
    #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.


Nashif, Anas
 

Yossi,
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.

Thanks,
Anas

-----Original Message-----
From: Havusha, Yossi [mailto:yossi.havusha(a)intel.com]
Sent: Thursday, October 27, 2016 4:44 AM
To: devel(a)lists.zephyrproject.org
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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

========
Overview
========
    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
      message.
    . SYS_LOG_BACKEND_FN is mapped to printk or printf according to kconfig.

=====
Goals
=====
    . 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
      drivers).

==========
Suggestion
==========
    . 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 */
    #if defined(CONFIG_LOGGER_EXTERNAL_HOOK)
    #define SYS_LOG_BACKEND_FN _syslog_hook
    #elif defined(CONFIG_STDOUT_CONSOLE)
    #include <stdio.h>
    #define SYS_LOG_BACKEND_FN printf
    #else
    #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.


Havusha, Yossi <yossi.havusha@...>
 

Hi Anas,
Thank you for your quick response,

I've created a Jira story ZEP-1172 and delivered the code to Gerrit https://tm-gerrit.ostc.intel.com/gerrit/4280

I'll work on a simple sample and will add that one as well.

Thanks,
Yossi

-----Original Message-----
From: Nashif, Anas
Sent: Tuesday, November 01, 2016 16:02
To: Havusha, Yossi <yossi.havusha(a)intel.com>; devel(a)lists.zephyrproject.org
Subject: RE: [devel] [RFC] [RFC] Add new SYS_LOG_BACKEND_FN to sys_log

Yossi,
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.

Thanks,
Anas


-----Original Message-----
From: Havusha, Yossi [mailto:yossi.havusha(a)intel.com]
Sent: Thursday, October 27, 2016 4:44 AM
To: devel(a)lists.zephyrproject.org
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 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

========
Overview
========
    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
      message.
    • SYS_LOG_BACKEND_FN is mapped to printk or printf according to kconfig.

=====
Goals
=====
    • 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
      drivers).

==========
Suggestion
==========
    • 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 */
    #if defined(CONFIG_LOGGER_EXTERNAL_HOOK)
    #define SYS_LOG_BACKEND_FN _syslog_hook
    #elif defined(CONFIG_STDOUT_CONSOLE)
    #include <stdio.h>
    #define SYS_LOG_BACKEND_FN printf
    #else
    #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.
---------------------------------------------------------------------
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.