简体   繁体   English

如何在glib中设置日志级别

[英]How can I set the log level in glib

Is there a way to change the log level in glib so eg in a release version of an application the debug messages of g_debug won't be logged to the stdout? 有没有办法改变glib中的日志级别,例如在应用程序的发行版中,g_debug的调试消息不会记录到stdout? Do I really need to implement my own log handler for this (g_log_set_handler)? 我真的需要为此实现自己的日志处理程序(g_log_set_handler)吗?

I have asked this question quite a while ago. 我刚才问过这个问题。 However things have changed in newer glib version which I just have discovered. 然而,我刚刚发现的更新的glib版本已经发生了变化。

Since glib version 2.32 debug messages are disabled and not shown by default. 由于glib版本2.32调试消息被禁用,默认情况下不显示。 If you want to turn them on the environment variable G_MESSAGES_DEBUG needs to be set to all. 如果要在环境变量上打开它们,则需要将G_MESSAGES_DEBUG设置为all。

G_MESSAGES_DEBUG=all /path/to/application

This option might be suitable for you and there is no need for a log handler. 此选项可能适合您,不需要日志处理程序。

See details http://developer.gnome.org/glib/2.32/glib-running.html 详情请见http://developer.gnome.org/glib/2.32/glib-running.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM