SND@LHC Software
Loading...
Searching...
No Matches
logger.py
Go to the documentation of this file.
1# -*- coding: utf-8 -*-
2
3import os
4import ROOT
5# TODO: add header to CMake
6ROOT.gROOT.ProcessLine('#include "' + os.path.join(os.path.expandvars('$FAIRSHIP'), 'utils', 'logger.hxx') + '"')
7
8def _make_wrapper(funcname):
9 def function(*args, **kwargs):
10 delim = kwargs.get('delim', ' ')
11 # Interleaves arguments with delimiters. No delimiter at the end.
12 args_with_delim = [val for pair in zip(args, len(args)*[delim]) for val in pair][:-1]
13 return ROOT.ship.__dict__[funcname](*map(type, args_with_delim))(*args_with_delim)
14 docstring = '''\
15 Python wrapper around the C++ function template ship::{}(Types... args).
16
17 Keyword arguments:
18 delim -- delimiter to be inserted between each argument (default \' \')
19 '''.format(funcname)
20 return function, docstring
21
23 # This function is used to avoid polluting the global namespace
24 for funcname in ('fatal', 'error', 'warn', 'info', 'debug'):
25 function, docstring = _make_wrapper(funcname)
26 globals()[funcname] = function
27 globals()[funcname].__doc__ = docstring
28
_add_wrappers()
Definition logger.py:22
_make_wrapper(funcname)
Definition logger.py:8