Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import logging
  2. from file2 import My_module
  3.  
  4. class A:
  5. def __init__(self):
  6. log_1 = logging.getLogger("log1")
  7. log_1.setLevel("DEBUG")
  8.  
  9. log_2 = logging.getLogger("log2")
  10. log_2.setLevel("ERROR")
  11.  
  12. obj = My_module()
  13.  
  14. import logging
  15. from file2 import My_module
  16.  
  17. class My_module:
  18. def __init__(self):
  19. # I want this logger to use the same settings set in file1.py,
  20. # since it uses the same logger_name as 'log2'
  21. log = logging.getLogger("log2")
  22.  
  23. # I should only see the 'ERROR' prints as per the 'log2' setting
  24. log.debug("My-mod DEBUG")
  25. log.info("My-mod INFO")
  26. log.error("My-mod ERROR")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement