Commit f7d03a842005b4705b90e9bb33cfa075601e7e34

Authored by Christian Herdtweck
1 parent dfbcabb9

crypto: use log_helper

Showing 1 changed file with 2 additions and 36 deletions
oletools/crypto.py
@@ -95,6 +95,7 @@ http://www.decalage.info/python/oletools @@ -95,6 +95,7 @@ http://www.decalage.info/python/oletools
95 # 2019-05-23 PL: - added DEFAULT_PASSWORDS list 95 # 2019-05-23 PL: - added DEFAULT_PASSWORDS list
96 # 2021-05-22 v0.60 PL: - added PowerPoint transparent password 96 # 2021-05-22 v0.60 PL: - added PowerPoint transparent password
97 # '/01Hannes Ruescher/01' (issue #627) 97 # '/01Hannes Ruescher/01' (issue #627)
  98 +# 2019-05-24 CH: - use log_helper
98 99
99 __version__ = '0.60' 100 __version__ = '0.60'
100 101
@@ -134,44 +135,9 @@ MAX_NESTING_DEPTH = 10 @@ -134,44 +135,9 @@ MAX_NESTING_DEPTH = 10
134 135
135 # === LOGGING ================================================================= 136 # === LOGGING =================================================================
136 137
137 -# TODO: use log_helper instead  
138 -  
139 -def get_logger(name, level=logging.CRITICAL+1):  
140 - """  
141 - Create a suitable logger object for this module.  
142 - The goal is not to change settings of the root logger, to avoid getting  
143 - other modules' logs on the screen.  
144 - If a logger exists with same name, reuse it. (Else it would have duplicate  
145 - handlers and messages would be doubled.)  
146 - The level is set to CRITICAL+1 by default, to avoid any logging.  
147 - """  
148 - # First, test if there is already a logger with the same name, else it  
149 - # will generate duplicate messages (due to duplicate handlers):  
150 - if name in logging.Logger.manager.loggerDict:  
151 - # NOTE: another less intrusive but more "hackish" solution would be to  
152 - # use getLogger then test if its effective level is not default.  
153 - logger = logging.getLogger(name)  
154 - # make sure level is OK:  
155 - logger.setLevel(level)  
156 - return logger  
157 - # get a new logger:  
158 - logger = logging.getLogger(name)  
159 - # only add a NullHandler for this logger, it is up to the application  
160 - # to configure its own logging:  
161 - logger.addHandler(logging.NullHandler())  
162 - logger.setLevel(level)  
163 - return logger  
164 -  
165 # a global logger object used for debugging: 138 # a global logger object used for debugging:
166 -log = get_logger('crypto') 139 +log = log_helper.get_or_create_silent_logger('crypto')
167 140
168 -def enable_logging():  
169 - """  
170 - Enable logging for this module (disabled by default).  
171 - This will set the module-specific logger level to NOTSET, which  
172 - means the main application controls the actual logging level.  
173 - """  
174 - log.setLevel(logging.NOTSET)  
175 141
176 142
177 def is_encrypted(some_file): 143 def is_encrypted(some_file):