Log levels

<< 点击显示目录 >>

主页  exOS使用助手 > exOS Automation Help > Development > Programming > Logging >

Log levels

日志级别定义了特定日志信息的严重程度。这需要从两方面考虑:

从日志记录的角度来看,也就是当你想记录某些信息时,级别指定了信息的重要性或严重性,这意味着例如EXOS_LOG_LEVEL_SUCCESS比EXOS_LOG_LEVEL_INFO具有更高的重要性。作为最低的严重性级别,EXOS_LOG_LEVEL_DEBUG可用于记录仅在调试情况下需要的信息。

从日志记录器或日志服务器的角度来看,级别应被视为一种过滤器,可以捕获或过滤不同级别的信息。例如,如果将级别设置为ERROR,则只有使用 exos_log_error() 记录的错误信息 才 会可见。另一方面,如果将其设置为 EXOS_LOG_LEVEL_DEBUG,则 会 记录EXOS_LOG_LEVEL_ERROR、 EXOS_LOG_LEVEL_WARNING、 EXOS_LOG_LEVEL_SUCCESS、 EXOS_LOG_LEVEL_INFO 和 EXOS_LOG_LEVEL_DEBUG 消息。如上文所述,过滤级别是通过日志服务器广播的配置在单个模块或应用程序中进行的。

EXOS_LOG_LEVEL

typedef enum
{
    EXOS_LOG_LEVEL_ERROR,
    EXOS_LOG_LEVEL_WARNING,
    EXOS_LOG_LEVEL_SUCCESS,
    EXOS_LOG_LEVEL_INFO,
    EXOS_LOG_LEVEL_DEBUG
} EXOS_LOG_LEVEL;

 

exos_log_level_error:

o作为过滤器:仅记录错误。

o作为模块:记录对应用程序有致命或严重影响的错误事件

exos_log_level_warning:

o作为过滤器:记录错误和警告。

o作为模块:针对可能对应用程序产生重大影响的事件记录警告

exos_log_level_success:

o作为过滤器:记录错误、警告和成功。

o作为一个模块:记录对您的机器具有重要意义的成功信息,例如,当您想表明系统已正确启动时

exos_log_level_info:

o作为过滤器:记录错误、警告、成功和信息。

o作为模块:日志信息可提供更详细的应用程序事件信息

exos_log_level_debug:

o作为过滤器:记录所有事件。

o作为一个模块:如果要跟踪应用程序中的特定事件,则记录调试信息。 必要时与 EXOS_LOG_TYPE_VERBOSE结合使用 。


The log level defines the severity of the certain log message. This needs to be considered from two sides:
 

From the logging perspective, that is - when you want to log something, the level specifies the importance or severity of the message, meaning that for example EXOS_LOG_LEVEL_SUCCESS has a higher importance than for example EXOS_LOG_LEVEL_INFO. As the lowest severity level, there is the EXOS_LOG_LEVEL_DEBUG, which can be used for logging information that is only needed in debugging situations.

From the logger or log-server perspective, the level should be considered as a filter, that enables the capturing or filtering of messages on different levels. For example, if you set the level to ERROR, only error messages logged with exos_log_error() will be visible. On the other hand, if you set it to EXOS_LOG_LEVEL_DEBUG, then EXOS_LOG_LEVEL_ERROR, EXOS_LOG_LEVEL_WARNING, EXOS_LOG_LEVEL_SUCCESS, EXOS_LOG_LEVEL_INFO and EXOS_LOG_LEVEL_DEBUG messages will be logged. As mentioned on the top, the filtering of the level takes place on the individual module or application via the configuration broadcast by the log-server.

EXOS_LOG_LEVEL

typedef enum
{
     EXOS_LOG_LEVEL_ERROR,
     EXOS_LOG_LEVEL_WARNING,
     EXOS_LOG_LEVEL_SUCCESS,
     EXOS_LOG_LEVEL_INFO,
     EXOS_LOG_LEVEL_DEBUG
} EXOS_LOG_LEVEL;

EXOS_LOG_LEVEL_ERROR:

oAs a filter: Log only error.

oAs a module: Log errors for events that have fatal or severe impact on your application

EXOS_LOG_LEVEL_WARNING:

oAs a filter: Log error and warning.

oAs a module: Log warnings for events that might have substantial impact on your application

EXOS_LOG_LEVEL_SUCCESS:

oAs a filter: Log error, warning and success.

oAs a module: Log success messages that are of significant importance to your machine, i.e. when you want to indicate that the system started up correctly

EXOS_LOG_LEVEL_INFO:

oAs a filter: Log error, warning success and info.

oAs a module: Log info for more elaborate information of your applications events

EXOS_LOG_LEVEL_DEBUG:

oAs a filter: Log everything.

oAs a module: Log debug messages if you are tracing down specific things in your applications. Combined with EXOS_LOG_TYPE_VERBOSE, if needed.