Log types

<< 点击显示目录 >>

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

Log types

如果能打开或关闭特定信息的日志记录(与实际日志级别无关),可能会非常方便。因此,我们引入了多种日志类型。由于日志类型具有位编码性质,因此可以为一条日志信息指定一个或多个日志类型。

另一方面,还可以设置过滤器,只允许记录配置中已启用日志类型的信息。这些过滤器是日志级别的附加设置。

下面的示例显示了如何记录一条冗长的用户调试信息:

...
exos_log_debug(&logger, EXOS_LOG_TYPE_USER + EXOS_LOG_TYPE_VERBOSE, "这是调试时才需要的信息");
...

EXOS_LOG_TYPE

typedef enum
{
     EXOS_LOG_TYPE_ALWAYS = 0,
     EXOS_LOG_TYPE_USER = 1,
     EXOS_LOG_TYPE_SYSTEM = 2,
     EXOS_LOG_TYPE_VERBOSE = 4,
} EXOS_LOG_TYPE;
 

exos_log_type_always:无论日志服务器上激活了哪种类型的过滤器,您都希望将其传递给日志服务器的日志内容。只根据当前级别进行过滤。

EXOS_LOG_TYPE_USER:如果您希望将来能过滤掉与应用程序相关的日志信息(例如只查看系统日志),那么如果没有其他原因,就应该使用这种类型。

EXOS_LOG_TYPE_SYSTEM:所有 exos 内部模块都使用 EXOS_LOG_TYPE_SYSTEM 开关记录日志,在记录应用程序日志时,不应使用此开关(除非有充分的理由)。

EXOS_LOG_TYPE_VERBOSE:如果您的日志信息有时可能会淹没日志记录器,则应设置 EXOS_TYPE_VERBOSE 选项,以表明这些数据确实超出了通常需要查看的范围。
 

如果 EXOS_LOG_TYPE_VERBOSE 与 EXOS_LOG_TYPE_SYSTEM 开关 相结合  (从过滤角度看,即从配置角度看,而不是从应用程序角度看),则内部共享内存日志记录将被激活。这肯定会在日志记录器中提供更广泛的信息,但并不是说日志记录器会被淹没,而是在追踪通信中的错误时非常有用。


It might become handy to be able to switch the logging of specific messages on or off - independent of their actual log level. Therefore, serveral log types have been introduced. Due to the bit-coded nature of log types, one or more log types can be assigned to a log message.

On the other hand, filters can be set that only allow messages to be logged for which the log type is enabled in the configuration. Those filters are set additional to log level.

The following example shows how to log a verbose user debug message:

...
    exos_log_debug(&logger, EXOS_LOG_TYPE_USER + EXOS_LOG_TYPE_VERBOSE, "this is information that is just needed in debug situations");
...

EXOS_LOG_TYPE

typedef enum
{
     EXOS_LOG_TYPE_ALWAYS = 0,
     EXOS_LOG_TYPE_USER = 1,
     EXOS_LOG_TYPE_SYSTEM = 2,
     EXOS_LOG_TYPE_VERBOSE = 4,
} EXOS_LOG_TYPE;
 

EXOS_LOG_TYPE_ALWAYS: Things you want to log that you would like to pass to the log-server regardless of the type-filter that is active on the log-server. Only filtered with the current level.

EXOS_LOG_TYPE_USER: If you want to be able to filter out application related log messages in future (and for example only see system logs), this is the type you should use if no other reason not to.

EXOS_LOG_TYPE_SYSTEM: All exos-internal modules log with the EXOS_LOG_TYPE_SYSTEM switch, and you should not use this switch when logging in your application (unless you see a good reason for it).

EXOS_LOG_TYPE_VERBOSE: If you have log messages that might at times flood the logger, you should set the EXOS_TYPE_VERBOSE option to indicate that this data is indeed more than what is normally interesting to look at.
 

If EXOS_LOG_TYPE_VERBOSE is combined with the EXOS_LOG_TYPE_SYSTEM switch from the filter perspecitve (that is from the configuration point of view, not the application), the internal shared memory logging is activated. This will surely give more extensive information in the logger, not to say flood the logger, but can be useful when tracing errors in the communication.