+def _get_log_level_argument_name(log_level):
+ # type: (lttngctl.LogLevel) -> str
+ if isinstance(log_level, lttngctl.UserLogLevel):
+ return {
+ lttngctl.UserLogLevel.EMERGENCY: "EMER",
+ lttngctl.UserLogLevel.ALERT: "ALERT",
+ lttngctl.UserLogLevel.CRITICAL: "CRIT",
+ lttngctl.UserLogLevel.ERROR: "ERR",
+ lttngctl.UserLogLevel.WARNING: "WARNING",
+ lttngctl.UserLogLevel.NOTICE: "NOTICE",
+ lttngctl.UserLogLevel.INFO: "INFO",
+ lttngctl.UserLogLevel.DEBUG_SYSTEM: "DEBUG_SYSTEM",
+ lttngctl.UserLogLevel.DEBUG_PROGRAM: "DEBUG_PROGRAM",
+ lttngctl.UserLogLevel.DEBUG_PROCESS: "DEBUG_PROCESS",
+ lttngctl.UserLogLevel.DEBUG_MODULE: "DEBUG_MODULE",
+ lttngctl.UserLogLevel.DEBUG_UNIT: "DEBUG_UNIT",
+ lttngctl.UserLogLevel.DEBUG_FUNCTION: "DEBUG_FUNCTION",
+ lttngctl.UserLogLevel.DEBUG_LINE: "DEBUG_LINE",
+ lttngctl.UserLogLevel.DEBUG: "DEBUG",
+ }[log_level]
+ elif isinstance(log_level, lttngctl.JULLogLevel):
+ return {
+ lttngctl.JULLogLevel.OFF: "OFF",
+ lttngctl.JULLogLevel.SEVERE: "SEVERE",
+ lttngctl.JULLogLevel.WARNING: "WARNING",
+ lttngctl.JULLogLevel.INFO: "INFO",
+ lttngctl.JULLogLevel.CONFIG: "CONFIG",
+ lttngctl.JULLogLevel.FINE: "FINE",
+ lttngctl.JULLogLevel.FINER: "FINER",
+ lttngctl.JULLogLevel.FINEST: "FINEST",
+ lttngctl.JULLogLevel.ALL: "ALL",
+ }[log_level]
+ elif isinstance(log_level, lttngctl.Log4jLogLevel):
+ return {
+ lttngctl.Log4jLogLevel.OFF: "OFF",
+ lttngctl.Log4jLogLevel.FATAL: "FATAL",
+ lttngctl.Log4jLogLevel.ERROR: "ERROR",
+ lttngctl.Log4jLogLevel.WARN: "WARN",
+ lttngctl.Log4jLogLevel.INFO: "INFO",
+ lttngctl.Log4jLogLevel.DEBUG: "DEBUG",
+ lttngctl.Log4jLogLevel.TRACE: "TRACE",
+ lttngctl.Log4jLogLevel.ALL: "ALL",
+ }[log_level]
+ elif isinstance(log_level, lttngctl.PythonLogLevel):
+ return {
+ lttngctl.PythonLogLevel.CRITICAL: "CRITICAL",
+ lttngctl.PythonLogLevel.ERROR: "ERROR",
+ lttngctl.PythonLogLevel.WARNING: "WARNING",
+ lttngctl.PythonLogLevel.INFO: "INFO",
+ lttngctl.PythonLogLevel.DEBUG: "DEBUG",
+ lttngctl.PythonLogLevel.NOTSET: "NOTSET",
+ }[log_level]
+
+ raise TypeError("Unknown log level type")
+
+
+def _get_log_level_from_mi_log_level_name(mi_log_level_name):
+ # type: (str) -> lttngctl.LogLevel
+ return {
+ "TRACE_EMERG": lttngctl.UserLogLevel.EMERGENCY,
+ "TRACE_ALERT": lttngctl.UserLogLevel.ALERT,
+ "TRACE_CRIT": lttngctl.UserLogLevel.CRITICAL,
+ "TRACE_ERR": lttngctl.UserLogLevel.ERROR,
+ "TRACE_WARNING": lttngctl.UserLogLevel.WARNING,
+ "TRACE_NOTICE": lttngctl.UserLogLevel.NOTICE,
+ "TRACE_INFO": lttngctl.UserLogLevel.INFO,
+ "TRACE_DEBUG_SYSTEM": lttngctl.UserLogLevel.DEBUG_SYSTEM,
+ "TRACE_DEBUG_PROGRAM": lttngctl.UserLogLevel.DEBUG_PROGRAM,
+ "TRACE_DEBUG_PROCESS": lttngctl.UserLogLevel.DEBUG_PROCESS,
+ "TRACE_DEBUG_MODULE": lttngctl.UserLogLevel.DEBUG_MODULE,
+ "TRACE_DEBUG_UNIT": lttngctl.UserLogLevel.DEBUG_UNIT,
+ "TRACE_DEBUG_FUNCTION": lttngctl.UserLogLevel.DEBUG_FUNCTION,
+ "TRACE_DEBUG_LINE": lttngctl.UserLogLevel.DEBUG_LINE,
+ "TRACE_DEBUG": lttngctl.UserLogLevel.DEBUG,
+ "JUL_OFF": lttngctl.JULLogLevel.OFF,
+ "JUL_SEVERE": lttngctl.JULLogLevel.SEVERE,
+ "JUL_WARNING": lttngctl.JULLogLevel.WARNING,
+ "JUL_INFO": lttngctl.JULLogLevel.INFO,
+ "JUL_CONFIG": lttngctl.JULLogLevel.CONFIG,
+ "JUL_FINE": lttngctl.JULLogLevel.FINE,
+ "JUL_FINER": lttngctl.JULLogLevel.FINER,
+ "JUL_FINEST": lttngctl.JULLogLevel.FINEST,
+ "JUL_ALL": lttngctl.JULLogLevel.ALL,
+ "LOG4J_OFF": lttngctl.Log4jLogLevel.OFF,
+ "LOG4J_FATAL": lttngctl.Log4jLogLevel.FATAL,
+ "LOG4J_ERROR": lttngctl.Log4jLogLevel.ERROR,
+ "LOG4J_WARN": lttngctl.Log4jLogLevel.WARN,
+ "LOG4J_INFO": lttngctl.Log4jLogLevel.INFO,
+ "LOG4J_DEBUG": lttngctl.Log4jLogLevel.DEBUG,
+ "LOG4J_TRACE": lttngctl.Log4jLogLevel.TRACE,
+ "LOG4J_ALL": lttngctl.Log4jLogLevel.ALL,
+ "PYTHON_CRITICAL": lttngctl.PythonLogLevel.CRITICAL,
+ "PYTHON_ERROR": lttngctl.PythonLogLevel.ERROR,
+ "PYTHON_WARNING": lttngctl.PythonLogLevel.WARNING,
+ "PYTHON_INFO": lttngctl.PythonLogLevel.INFO,
+ "PYTHON_DEBUG": lttngctl.PythonLogLevel.DEBUG,
+ "PYTHON_NOTSET": lttngctl.PythonLogLevel.NOTSET,
+ }[mi_log_level_name]
+
+
+def _get_tracepoint_event_rule_class_from_domain_type(domain_type):
+ # type: (lttngctl.TracingDomain) -> Type[lttngctl.UserTracepointEventRule] | Type[lttngctl.Log4jTracepointEventRule] | Type[lttngctl.JULTracepointEventRule] | Type[lttngctl.PythonTracepointEventRule] | Type[lttngctl.KernelTracepointEventRule]
+ return {
+ lttngctl.TracingDomain.User: lttngctl.UserTracepointEventRule,
+ lttngctl.TracingDomain.JUL: lttngctl.JULTracepointEventRule,
+ lttngctl.TracingDomain.Log4j: lttngctl.Log4jTracepointEventRule,
+ lttngctl.TracingDomain.Python: lttngctl.PythonTracepointEventRule,
+ lttngctl.TracingDomain.Kernel: lttngctl.KernelTracepointEventRule,
+ }[domain_type]
+
+