LibInsane: Libinsane logs

| LibInsane 1.0.10 Cross-platform Cross-API Cross-driver Cross-image-scanner Image Scan Library

Loading...
Searching...
No Matches
Libinsane logs

### Libinsane

By default, all logs from libinsane go to stderr. This may not be what you want (debug logs are very verbose).

This can be changed by defining a callback to handle logs using functions from log.h.

### Libinsane-gobject

You have to create an object implementing the interface Libinsane.Logger and pass it to libinsane_register_loggger().

#### Example 1

from gi.repository import Libinsane # noqa: E402
class ExampleLogger(GObject.GObject, Libinsane.Logger):
def do_log(self, lvl, msg):
if lvl <= Libinsane.LogLevel.WARNING:
return
print("{}: {}".format(lvl.value_nick, msg))
def main():
Libinsane.register_logger(ExampleLogger())

#### Example 2

class ExampleLogger(GObject.GObject, Libinsane.Logger):
def do_log(self, lvl, msg):
if lvl <= Libinsane.LogLevel.INFO:
return
print("{}: {}".format(lvl.value_nick, msg))
sys.stdout.flush()
Libinsane.register_logger(ExampleLogger())