Add 'log4j2' domain to common test code
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 22 May 2024 20:44:30 +0000 (16:44 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 30 Aug 2024 20:39:12 +0000 (16:39 -0400)
Change-Id: I84961823eb875c673e525d83d8096291506c1edb
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
tests/regression/tools/base-path/load-stream-extra-path.lttng
tests/regression/tools/save-load/load-42-complex.lttng
tests/regression/tools/save-load/tracker_legacy_all.lttng
tests/regression/tools/save-load/tracker_legacy_none.lttng
tests/regression/tools/save-load/tracker_legacy_selective.lttng
tests/utils/lttngtest/lttng.py
tests/utils/lttngtest/lttngctl.py

index 973d67a6d2ed2a9f3a8c5b91987c989c68fcfcfc..b2ecc5695c8bcdf63c24f0d8f93c5ff458abe952 100644 (file)
                                <buffer_type>PER_UID</buffer_type>
                                <channels/>
                        </domain>
+                       <domain>
+                               <type>LOG4J2</type>
+                               <buffer_type>PER_UID</buffer_type>
+                               <channels/>
+                       </domain>
                        <domain>
                                <type>PYTHON</type>
                                <buffer_type>PER_UID</buffer_type>
index a80ce5302beea72ae4dc9e893f093f6c5e8ccd0a..4f6041f62d3ec11ce34eac732863b1403f7c7846 100644 (file)
                                <buffer_type>PER_UID</buffer_type>
                                <channels/>
                        </domain>
+                       <domain>
+                               <type>LOG4J2</type>
+                               <buffer_type>PER_UID</buffer_type>
+                               <channels/>
+                       </domain>
                        <domain>
                                <type>PYTHON</type>
                                <buffer_type>PER_UID</buffer_type>
index 5552345f351286003973576bdebf95da3479ee25..bf4940252948a36d555b4dd33730b757c1ffbaee 100644 (file)
                                <buffer_type>PER_UID</buffer_type>
                                <channels/>
                        </domain>
+                       <domain>
+                               <type>LOG4J2</type>
+                               <buffer_type>PER_UID</buffer_type>
+                               <channels/>
+                       </domain>
                        <domain>
                                <type>PYTHON</type>
                                <buffer_type>PER_UID</buffer_type>
index 47aeb29fb06dadadcb6a8979fda55c56d30a3660..5160e1da91356c153bc9de91cfd09460bd8cd17a 100644 (file)
                                <buffer_type>PER_UID</buffer_type>
                                <channels/>
                        </domain>
+                       <domain>
+                               <type>LOG4J2</type>
+                               <buffer_type>PER_UID</buffer_type>
+                               <channels/>
+                       </domain>
                        <domain>
                                <type>PYTHON</type>
                                <buffer_type>PER_UID</buffer_type>
index 11c0169aabf0f5452413b87c9208832a6e14b73b..7be33494023da37848416d8a1da4d3bcfbe81284 100644 (file)
                                <buffer_type>PER_UID</buffer_type>
                                <channels/>
                        </domain>
+                       <domain>
+                               <type>LOG4J2</type>
+                               <buffer_type>PER_UID</buffer_type>
+                               <channels/>
+                       </domain>
                        <domain>
                                <type>PYTHON</type>
                                <buffer_type>PER_UID</buffer_type>
index 3598cc940ba5bf3c686d314aa5d80d9fbd5c4273..3d59776578556bb8cd02414fbb177904a3d7743c 100644 (file)
@@ -42,6 +42,7 @@ def _get_domain_option_name(domain):
         lttngctl.TracingDomain.User: "userspace",
         lttngctl.TracingDomain.Kernel: "kernel",
         lttngctl.TracingDomain.Log4j: "log4j",
+        lttngctl.TracingDomain.Log4j2: "log4j2",
         lttngctl.TracingDomain.Python: "python",
         lttngctl.TracingDomain.JUL: "jul",
     }[domain]
@@ -53,6 +54,7 @@ def _get_domain_xml_mi_name(domain):
         lttngctl.TracingDomain.User: "UST",
         lttngctl.TracingDomain.Kernel: "KERNEL",
         lttngctl.TracingDomain.Log4j: "LOG4J",
+        lttngctl.TracingDomain.Log4j2: "LOG4J2",
         lttngctl.TracingDomain.Python: "PYTHON",
         lttngctl.TracingDomain.JUL: "JUL",
     }[domain]
@@ -121,6 +123,17 @@ def _get_log_level_argument_name(log_level):
             lttngctl.Log4jLogLevel.TRACE: "TRACE",
             lttngctl.Log4jLogLevel.ALL: "ALL",
         }[log_level]
+    elif isinstance(log_level, lttngctl.Log4j2LogLevel):
+        return {
+            lttngctl.Log4j2LogLevel.OFF: "OFF",
+            lttngctl.Log4j2LogLevel.FATAL: "FATAL",
+            lttngctl.Log4j2LogLevel.ERROR: "ERROR",
+            lttngctl.Log4j2LogLevel.WARN: "WARN",
+            lttngctl.Log4j2LogLevel.INFO: "INFO",
+            lttngctl.Log4j2LogLevel.DEBUG: "DEBUG",
+            lttngctl.Log4j2LogLevel.TRACE: "TRACE",
+            lttngctl.Log4j2LogLevel.ALL: "ALL",
+        }[log_level]
     elif isinstance(log_level, lttngctl.PythonLogLevel):
         return {
             lttngctl.PythonLogLevel.CRITICAL: "CRITICAL",
@@ -169,6 +182,14 @@ def _get_log_level_from_mi_log_level_name(mi_log_level_name):
         "LOG4J_DEBUG": lttngctl.Log4jLogLevel.DEBUG,
         "LOG4J_TRACE": lttngctl.Log4jLogLevel.TRACE,
         "LOG4J_ALL": lttngctl.Log4jLogLevel.ALL,
+        "LOG4J2_OFF": lttngctl.Log4j2LogLevel.OFF,
+        "LOG4J2_FATAL": lttngctl.Log4j2LogLevel.FATAL,
+        "LOG4J2_ERROR": lttngctl.Log4j2LogLevel.ERROR,
+        "LOG4J2_WARN": lttngctl.Log4j2LogLevel.WARN,
+        "LOG4J2_INFO": lttngctl.Log4j2LogLevel.INFO,
+        "LOG4J2_DEBUG": lttngctl.Log4j2LogLevel.DEBUG,
+        "LOG4J2_TRACE": lttngctl.Log4j2LogLevel.TRACE,
+        "LOG4J2_ALL": lttngctl.Log4j2LogLevel.ALL,
         "PYTHON_CRITICAL": lttngctl.PythonLogLevel.CRITICAL,
         "PYTHON_ERROR": lttngctl.PythonLogLevel.ERROR,
         "PYTHON_WARNING": lttngctl.PythonLogLevel.WARNING,
@@ -179,11 +200,12 @@ def _get_log_level_from_mi_log_level_name(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]
+    # type: (lttngctl.TracingDomain) -> Type[lttngctl.UserTracepointEventRule] | Type[lttngctl.Log4jTracepointEventRule] | Type[lttngctl.Log4j2TracepointEventRule] | 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.Log4j2: lttngctl.Log4j2TracepointEventRule,
         lttngctl.TracingDomain.Python: lttngctl.PythonTracepointEventRule,
         lttngctl.TracingDomain.Kernel: lttngctl.KernelTracepointEventRule,
     }[domain_type]
index 5b937dc8acfd8cecc885fdb47af322f75236c91e..6b8f6a969f3bde56e70b7036f50af145e3cda2c9 100644 (file)
@@ -81,7 +81,8 @@ class TracingDomain(enum.Enum):
 
     User = "User space tracing domain"
     Kernel = "Linux kernel tracing domain."
-    Log4j = "Log4j tracing back-end."
+    Log4j = "Log4j 1.x tracing back-end."
+    Log4j2 = "Log4j 2.x tracing back-end."
     JUL = "Java Util Logging tracing back-end."
     Python = "Python logging module tracing back-end."
 
@@ -164,6 +165,18 @@ class Log4jLogLevel(LogLevel):
     ALL = -2147483648
 
 
+@enum.unique
+class Log4j2LogLevel(LogLevel):
+    OFF = 0
+    FATAL = 100
+    ERROR = 200
+    WARN = 300
+    INFO = 400
+    DEBUG = 500
+    TRACE = 600
+    ALL = 2147483647
+
+
 @enum.unique
 class PythonLogLevel(LogLevel):
     CRITICAL = 50
@@ -304,6 +317,41 @@ class Log4jTracepointEventRule(TracepointEventRule):
         return self._name_pattern_exclusions
 
 
+class Log4j2TracepointEventRule(TracepointEventRule):
+    def __init__(
+        self,
+        name_pattern=None,  # type: Optional[str]
+        filter_expression=None,  # type: Optional[str]
+        log_level_rule=None,  # type: Optional[LogLevelRule]
+        name_pattern_exclusions=None,  # type: Optional[List[str]]
+    ):
+        TracepointEventRule.__init__(self, name_pattern, filter_expression)
+        self._log_level_rule = log_level_rule  # type: Optional[LogLevelRule]
+        self._name_pattern_exclusions = (
+            name_pattern_exclusions
+        )  # type: Optional[List[str]]
+
+        if log_level_rule and not isinstance(log_level_rule.level, Log4j2LogLevel):
+            raise ValueError("Log level rule must use a Log4j2LogLevel as its value")
+
+    def _equals(self, other):
+        # type (Log4jTracepointEventRule) -> bool
+        return (
+            self.log_level_rule == other.log_level_rule
+            and self.name_pattern_exclusions == other.name_pattern_exclusions
+        )
+
+    @property
+    def log_level_rule(self):
+        # type: () -> Optional[LogLevelRule]
+        return self._log_level_rule
+
+    @property
+    def name_pattern_exclusions(self):
+        # type: () -> Optional[List[str]]
+        return self._name_pattern_exclusions
+
+
 class JULTracepointEventRule(TracepointEventRule):
     def __init__(
         self,
This page took 0.028671 seconds and 4 git commands to generate.