I need add some log informations with souce file name, function name,
line number etc...
I have check the official docs, but not found...
so, how to do for it ?
I need add some log informations with souce file name, function name,
line number etc...
I have check the official docs, but not found...
so, how to do for it ?
This is usually done via GLib logging.
For example try this Vala application:
int main (string[] args) {
// info () is not shown by default, set G_MESSAGES_DEBUG=all in your shell to see them
info ("Hello World");
warning ("Hello World");
//assert_true (false);
// error () terminates the program
error ("Hello World");
return 0;
}
The output is:
$ G_MESSAGES_DEBUG=all src/glib_logging_test
** INFO: glib_logging_test.vala:4: Hello World
** (process:10129): WARNING **: glib_logging_test.vala:5: Hello World
** (process:10129): ERROR **: glib_logging_test.vala:9: Hello World
Trace/Breakpoint ausgelöst
You can also set G_DEBUG
in addition to G_MESSAGES_DEBUG
, see running GLib applications.
You can install a custom handler with Log.set_handler ()
as well.
There is also Log.FILE
, Log.LINE
, Log.METHOD
for the raw information equivalent to the C macros.
© 2022 - 2024 — McMap. All rights reserved.
--ccode
), it's important to set the--debug
flag so that the macros can resolve file, line and method properly. – Grays