r9y9 / pylibfreenect2

A python interface for libfreenect2
http://r9y9.github.io/pylibfreenect2/latest/
Other
138 stars 53 forks source link

Logging Request #16

Open gargoyle3333 opened 8 years ago

gargoyle3333 commented 8 years ago

Hi, this is a feature request - is there a way to convert print statements to use loggers instead? This would allow me to disable output completely or redirect output to a file more easily.

r9y9 commented 8 years ago

There is no way to do that for now, but it should definitely be possible. Will try to implement if I get a chance.

r9y9 commented 8 years ago

@gargoyle3333 I implemented logging utilities of libfreenect2. You can change logger level by creating a new logger:

from pylibfreenect2 import createConsoleLogger, setGlobalLogger
from pylibfreenect2 import LoggerLevel

logger = createConsoleLogger(LoggerLevel.Debug)
setGlobalLogger(logger)

To disable,

setGlobalLogger(None)

if you want to replace print statements with libfreenecg2's logger, you can try the following:

logger.log(LoggerLevel.Debug, b"message")