1from ._daq_ers_py
import *
16 "extracts context for an ERS issue"
17 __file = re.sub(
r'\.pyc$',
'.py', __file__ )
20 self.
stack = [f[0]
for f
in inspect.stack() \
22 and (
'self' not in f[0].f_locals\
23 or not isinstance(f[0].f_locals[
'self'],
ers.PyIssue))]
25 class_name =
lambda :
'self' in self.
stack[0].f_locals \
26 and self.
stack[0].f_locals[
'self'].__class__.__name__ +
'.'\
32 except Exception
as exx:
38 self.
cwd = os.getcwd()
48 "base class for Python ERS exceptions"
49 __verbosity = int( os.getenv(
"DUNEDAQ_ERS_VERBOSITY_LEVEL",
"2" ) )
52 Exception.__init__( self, message, kwargs, cause )
60 self.
__parameters = dict([ (str(k), str(v))
for (k,v)
in list(kwargs.items()) ])
61 self.__dict__.update( kwargs )
78 return self.__class__.__name__ == cname
and True or False
83'''Wrap a message string as an ERS issue'''
88 package_name =
"erspy"
91 rpc =
ers.RemoteProcessContext(ct.host_name,ct.process_id,ct.thread_id,ct.cwd,ct.user_id,ct.user_name,ct.application_name)
92 rc =
ers.RemoteContext(package_name,ct.file_name,ct.line_number,ct.function_name,rpc)
97'''Bunch of functions to wrap a text string and inject it as an ers message of different types'''
99 "sends msg to the debug stream"
103 "sends msg to the log stream"
107 "sends msg to the information stream"
110'''These just inject an issue into the more serious streams.
111 The only thing these add over just calling the bound ers function directly is that they
112 warn you if you use the wrong type of argument.
113 Mainly here because the old ers.py had them, and they provide a consistency of interface
114 rather than forcing the user to use these calls for some things and direct ers calls for others'''
116 "sends issue to the warning stream"
118 'Only an instance of ers.Issue sub-class can be sent to the ers.warning stream'
122 "sends issue to the error stream"
124 'Only an instance of ers.Issue sub-class can be sent to the ers.error stream'
128 "sends issue to the fatal stream"
130 'Only an instance of ers.Issue sub-class can be sent to the ers.fatal stream'
Base class for any user define issue.
const Context & context() const
Context of the issue.
const std::vector< std::string > & qualifiers() const
return array of qualifiers
const std::string & message() const
General cause of the issue.
const string_map & parameters() const
return array of parameters
std::string time(const std::string &format="%Y-%b-%d %H:%M:%S", bool isUTC=false) const
string representation of local time of the issue
const Issue * cause() const
return the cause Issue of this Issue
__init__(self, message, kwargs, cause)
isInstanceOf(self, cname)
void warning(const Issue &issue)
void info(const Issue &issue)
void log(const Issue &issue)
void debug(const Issue &issue, int level=debug_level())
void fatal(const Issue &issue)
void error(const Issue &issue)