This is the formatting string that I am using for logging:
\'%(asctime)s - %(levelname)-10s - %(funcName)s - %(message)s\'
But to show the logg
First of all according to your code it's clear why it happens, levelname
and funcName
"belongs" to self.log
so when you call to self.log(level, line)
the levelname
is level
and funcName
is line
.
You have 2 options IMHO:
To use inspect
module to get the current method and to deliver it inside the message, then you can parse it and to use it very easily.
A better approach will be to use inspect
inside split_line to get the "father" method
you can change the number(3) in the following code to "play" with the hierarchy of the methods.
example of using inspect to get current method
from inspect import stack
class Foo:
def __init__(self):
print stack()[0][3]
f = Foo()