I have a class inherited by many other classes. Related class have a logging method and logs some extra parameters beside the text I wish to log:
import logging
# some lines to set logger
log = logging.getLogger('some_loger')
class SomeClass:
def log_it(self, log_text):
log.info(self.some_param + self.some_other_param + log_text + self.some_another_param)
And in any file that inherits SomeClass
:
class MyOtherClass(SomeClass):
def some_method(self):
...
...
self.log_it('let me log this text')
I also wish to log the current line number (line that calls self.log_it
) so I can easily find the current logging line in the related file.
What is the best pythonic way to do this?