print


Description:


[ Version ( since = "1.30" ) ]
public void print (int output_mode, string msg)

The only purpose of this function is to give access to print or printerr from pygobject.

libnm can do debug logging by setting LIBNM_CLIENT_DEBUG and uses thereby printerr or print. A plain "print()" function in python is not in sync with these functions (it implements additional buffering). By using print, the same logging mechanisms can be used.

LIBNM_CLIENT_DEBUG is a list of keywords separated by commas. The keyword "trace" enables printing messages of the lowest up to the highest severity. Likewise, the severities "debug", "warn" ("warning") and "error" are honored in similar way. Setting the flags "ERROR" or "WARN" ("WARNING") implies that respective levels are enabled, but also are ERROR messages printed with critical and WARN messages with warning. Together with G_DEBUG="fatal-warnings" or G_DEBUG="fatal-critical" this can be used to abort the program on errors. Note that all <error> messages imply an unexpected data on the D-Bus API ( due to a bug). <warn> also implies unexepected data, but that can happen when using different versions of libnm and daemon. For testing, it is good to turn these into assertions.

By default, messages are printed to stderr, unless LIBNM_CLIENT_DEBUG contains "stdout" flag. Also, libnm honors LIBNM_CLIENT_DEBUG_FILE environment. If this is set to a filename pattern (accepting "%p" for the process ID), then the debug log is written to that file instead of stderr/stdout. With output_mode zero, the same location will be written.

LIBNM_CLIENT_DEBUG_FILE is supported since 1.44. "ERROR", "WARN" and "WARNING" are supported since 1.46.

Parameters:

output_mode

if 1 it uses print. If 2, it uses printerr. If 0, it uses the same output as internal libnm debug logging does. That is, depending on LIBNM_CLIENT_DEBUG's "stdout" flag it uses print or printerr and if LIBNM_CLIENT_DEBUG_FILE is set, it writes the output to file instead

msg

the message to print. The function does not append a trailing newline.


Namespace: NM.Utils
Package: libnm