MCPcopy Create free account
hub / github.com/alibaba/GraphScope / ConditionalFormatter

Class ConditionalFormatter

python/graphscope/client/utils.py:231–254  ·  view source on GitHub ↗

Provide an option to disable format for some messages. Taken from https://stackoverflow.com/questions/34954373/disable-format-for-some-messages Examples: .. code:: python >>> import logging >>> import sys >>> handler = logging.StreamHandler(sys.std

Source from the content-addressed store, hash-verified

229
230
231class ConditionalFormatter(logging.Formatter):
232 """Provide an option to disable format for some messages.
233 Taken from https://stackoverflow.com/questions/34954373/disable-format-for-some-messages
234 Examples:
235 .. code:: python
236
237 >>> import logging
238 >>> import sys
239 >>> handler = logging.StreamHandler(sys.stdout)
240 >>> formatter = ConditionalFormatter('%(asctime)s %(levelname)s - %(message)s')
241 >>> handler.setFormatter(formatter)
242 >>> logger = logging.getLogger("graphscope")
243 >>> logger.setLevel("INFO")
244 >>> logger.addHandler(handler)
245 >>> logger.info("with formatting")
246 2020-12-21 13:44:52,537 INFO - with formatting
247 >>> logger.info("without formatting", extra={'simple': True})
248 without formatting
249 """
250
251 def format(self, record):
252 if hasattr(record, "simple") and record.simple:
253 return record.getMessage()
254 return logging.Formatter.format(self, record)
255
256
257class GSLogger(object):

Callers 1

initMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected