简体   繁体   中英

Is there a good way of coloring tf.logging (tensorflow terminal printing)?

I am an intense Tensorflow user. So far, when I need to print something, I used to use the logging library with coloredlogs . These are very useful, and I could see what is going on more easily:

import logging
import coloredlogs
logger = logging.getLogger(__name__)
coloredlogs.install(level='DEBUG', logger=logger, ...)
logger.debug("-- preparing network..")   <-- eg, debug in green, info in cyan, ...

However, Tensorflow actually provides built-in tf.logging . For compatibility, I decided to use it. In this case, is there a way that I can assign some colors to tf.logging.{debug, info, warning, ...} ?

The module coloredlogs works for Tenosorflow in-built logging too.

from tensorflow import logging
coloredlogs.install(level='DEBUG')
tf.logging.set_verbosity(tf.logging.DEBUG)

I tried this. Working perfectly. But you should set both logging verbosity to same. Or coloredlogs log verbosity should be higher.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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