mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 21:32:15 +01:00
27 lines
711 B
Python
27 lines
711 B
Python
# :coding: utf-8
|
|
# :copyright: Copyright (c) 2016 ftrack
|
|
|
|
|
|
from builtins import object
|
|
class LazyLogMessage(object):
|
|
'''A log message that can be evaluated lazily for improved performance.
|
|
|
|
Example::
|
|
|
|
# Formatting of string will not occur unless debug logging enabled.
|
|
logger.debug(LazyLogMessage(
|
|
'Hello {0}', 'world'
|
|
))
|
|
|
|
'''
|
|
|
|
def __init__(self, message, *args, **kwargs):
|
|
'''Initialise with *message* format string and arguments.'''
|
|
self.message = message
|
|
self.args = args
|
|
self.kwargs = kwargs
|
|
|
|
def __str__(self):
|
|
'''Return string representation.'''
|
|
return self.message.format(*self.args, **self.kwargs)
|
|
|