-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Use logging instead of print statements #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
+1 |
Hi, to disable the printing, you can use: >>> print("You can see me")
>>> with tl.ops.suppress_stdout():
>>> print("You can't see me")
>>> print("You can see me") |
hi @zsdonghao. it's not about how to suppress print, it's about logging info with more control.If we use logging, then we can config what and where to output .When we want to deploy tl to production environment as service, we need it to log the normal and exception messages.Besides we found some globals defined in layers.py set_keep = globals()
set_keep['_layers_name_list'] =[]
set_keep['name_reuse'] = False ,this piece of code make tl hard to deploy as service for multiple users. |
I second everything @haiy said. Both of those two pieces have bitten us as well. |
@haiy For production, as I know, people usually use TensorFlow Serving, threading is not necessary. May be I didn't get you point? or there are some reasons threading is better? |
@mitar Thanks, I will think about it carefully ~ |
Totally agree with the concerns over using print instead of logging. Things like I think we could just add the following to all the modules that needs logging (to create a logger hierarchy): import logging
logger = logging.getLogger(__name__) And use |
Also not sure why we need global variables to prevent layer name collisions, since after all the use of TensorFlow's variable scopes already handles that. Maybe it's also easier to just pass |
Just to repeat what I proposed in #306 The idea would be to make this output optional (default = True or False). I think there could be different ways to do this. 1. Solution - Create a verbose parameter in the Layer APISimple and backward compatible, a "verbose" parameter can be added to the Layer Class and influence the behavior of print_params() method. 2. Use the Logging module from TF.Why should we re-invent the wheel ? Everything is already implemented in Tensorflow. tf.logging._level_names ## outputs => {50: 'FATAL', 40: 'ERROR', 30: 'WARN', 20: 'INFO', 10: 'DEBUG'}
tf.logging.get_verbosity() ## outputs => 30 (default value)
tf.logging.set_verbosity(tf.logging.DEBUG)
tf.logging.get_verbosity() ## outputs => 10 We could for instance determine that for logging level <= 20 (INFO & DEBUG), we normally output the Tensorlayer informations, and we don't perform this action for any higher value. |
Replace print to logging in other modules (#207)
Replace print to logging in other modules (#207)
Code is full of print statements. Please use logging so that one can intercept output and control noisiness.
The text was updated successfully, but these errors were encountered: