1 |
charliebrady |
1.1 |
import logging |
2 |
|
|
import anaconda_log |
3 |
|
|
import inspect |
4 |
|
|
|
5 |
|
|
def log_method_call(d, *args, **kwargs): |
6 |
|
|
classname = d.__class__.__name__ |
7 |
|
|
stack = inspect.stack() |
8 |
|
|
methodname = stack[1][3] |
9 |
|
|
|
10 |
|
|
spaces = len(stack) * ' ' |
11 |
|
|
fmt = "%s%s.%s:" |
12 |
|
|
fmt_args = [spaces, classname, methodname] |
13 |
|
|
|
14 |
|
|
for arg in args: |
15 |
|
|
fmt += " %s ;" |
16 |
|
|
fmt_args.append(arg) |
17 |
|
|
|
18 |
|
|
for k, v in kwargs.items(): |
19 |
|
|
fmt += " %s: %s ;" |
20 |
|
|
fmt_args.extend([k, v]) |
21 |
|
|
|
22 |
|
|
logger.debug(fmt % tuple(fmt_args)) |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
logger = logging.getLogger("storage") |
26 |
|
|
logger.setLevel(logging.DEBUG) |
27 |
|
|
anaconda_log.logger.addFileHandler("/tmp/storage.log", logger, logging.DEBUG) |
28 |
|
|
anaconda_log.logger.addFileHandler("/dev/tty3", logger, logging.DEBUG) |