[logging] add MLR log region (#5250)

diff --git a/etc/cmake/options.cmake b/etc/cmake/options.cmake
index d065750..e9414a9 100644
--- a/etc/cmake/options.cmake
+++ b/etc/cmake/options.cmake
@@ -244,6 +244,7 @@
     target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_MEM=1")
     target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_MESHCOP=1")
     target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_MLE=1")
+    target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_MLR=1")
     target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_NETDATA=1")
     target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_NETDIAG=1")
     target_compile_definitions(ot-config INTERFACE "OPENTHREAD_CONFIG_LOG_PKT_DUMP=1")
diff --git a/examples/common-switches.mk b/examples/common-switches.mk
index 49713cd..59fc043 100644
--- a/examples/common-switches.mk
+++ b/examples/common-switches.mk
@@ -292,6 +292,7 @@
 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_MEM=1
 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_MESHCOP=1
 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_MLE=1
+LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_MLR=1
 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_NETDATA=1
 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_NETDIAG=1
 LOG_FLAGS += -DOPENTHREAD_CONFIG_LOG_PKT_DUMP=1
diff --git a/include/openthread/instance.h b/include/openthread/instance.h
index e0e4010..3b9fb46 100644
--- a/include/openthread/instance.h
+++ b/include/openthread/instance.h
@@ -53,7 +53,7 @@
  * @note This number versions both OpenThread platform and user APIs.
  *
  */
-#define OPENTHREAD_API_VERSION (15)
+#define OPENTHREAD_API_VERSION (16)
 
 /**
  * @addtogroup api-instance
diff --git a/include/openthread/platform/logging.h b/include/openthread/platform/logging.h
index 12f361c..df40aee 100644
--- a/include/openthread/platform/logging.h
+++ b/include/openthread/platform/logging.h
@@ -135,6 +135,7 @@
     OT_LOG_REGION_CORE     = 15, ///< OpenThread Core
     OT_LOG_REGION_UTIL     = 16, ///< Utility module
     OT_LOG_REGION_BBR      = 17, ///< Backbone Router (available since Thread 1.2)
+    OT_LOG_REGION_MLR      = 18, ///< Multicast Listener Registration (available since Thread 1.2)
 } otLogRegion;
 
 /**
diff --git a/src/core/common/logging.hpp b/src/core/common/logging.hpp
index eda0ac7..6e9ff16 100644
--- a/src/core/common/logging.hpp
+++ b/src/core/common/logging.hpp
@@ -90,6 +90,7 @@
 #define _OT_REGION_CORE_PREFIX "-CORE----: "
 #define _OT_REGION_UTIL_PREFIX "-UTIL----: "
 #define _OT_REGION_BBR_PREFIX "-BBR-----: "
+#define _OT_REGION_MLR_PREFIX "-MLR-----: "
 #else
 #define _OT_REGION_API_PREFIX _OT_REGION_SUFFIX
 #define _OT_REGION_MLE_PREFIX _OT_REGION_SUFFIX
@@ -108,6 +109,7 @@
 #define _OT_REGION_CORE_PREFIX _OT_REGION_SUFFIX
 #define _OT_REGION_UTIL_PREFIX _OT_REGION_SUFFIX
 #define _OT_REGION_BBR_PREFIX _OT_REGION_SUFFIX
+#define _OT_REGION_MLR_PREFIX _OT_REGION_SUFFIX
 #endif
 
 /**
@@ -484,6 +486,64 @@
 #endif
 
 /**
+ * @def otLogCritMlr
+ *
+ * This method generates a log with level critical for the Multicast Listener Registration (MLR) region.
+ *
+ * @param[in]  ...  Arguments for the format specification.
+ *
+ */
+
+/**
+ * @def otLogWarnMlr
+ *
+ * This method generates a log with level warning for the Multicast Listener Registration (MLR) region.
+ *
+ * @param[in]  ...  Arguments for the format specification.
+ *
+ */
+
+/**
+ * @def otLogNoteMlr
+ *
+ * This method generates a log with level note for the Multicast Listener Registration (MLR) region.
+ *
+ * @param[in]  ...  Arguments for the format specification.
+ *
+ */
+
+/**
+ * @def otLogInfoMlr
+ *
+ * This method generates a log with level info for the Multicast Listener Registration (MLR) region.
+ *
+ * @param[in]  ...  Arguments for the format specification.
+ *
+ */
+
+/**
+ * @def otLogDebgMlr
+ *
+ * This method generates a log with level debug for the Multicast Listener Registration (MLR) region.
+ *
+ * @param[in]  ...  Arguments for the format specification.
+ *
+ */
+#if OPENTHREAD_CONFIG_LOG_MLR == 1
+#define otLogCritMlr(...) otLogCrit(OT_LOG_REGION_MLR, _OT_REGION_MLR_PREFIX __VA_ARGS__)
+#define otLogWarnMlr(...) otLogWarn(OT_LOG_REGION_MLR, _OT_REGION_MLR_PREFIX __VA_ARGS__)
+#define otLogNoteMlr(...) otLogNote(OT_LOG_REGION_MLR, _OT_REGION_MLR_PREFIX __VA_ARGS__)
+#define otLogInfoMlr(...) otLogInfo(OT_LOG_REGION_MLR, _OT_REGION_MLR_PREFIX __VA_ARGS__)
+#define otLogDebgMlr(...) otLogDebg(OT_LOG_REGION_MLR, _OT_REGION_MLR_PREFIX __VA_ARGS__)
+#else
+#define otLogCritMlr(...)
+#define otLogWarnMlr(...)
+#define otLogNoteMlr(...)
+#define otLogInfoMlr(...)
+#define otLogDebgMlr(...)
+#endif
+
+/**
  * @def otLogCritNetData
  *
  * This method generates a log with level critical for the Network Data region.
@@ -1524,6 +1584,74 @@
 #endif
 
 /**
+ * @def otDumpCritMlr
+ *
+ * This method generates a memory dump with log level critical and region Multicast Listener Registration (MLR).
+ *
+ * @param[in]  aId          A pointer to a NULL-terminated string that is printed before the bytes.
+ * @param[in]  aBuf         A pointer to the buffer.
+ * @param[in]  aLength      Number of bytes to print.
+ *
+ */
+
+/**
+ * @def otDumpWarnMlr
+ *
+ * This method generates a memory dump with log level warning and region Multicast Listener Registration (MLR).
+ *
+ * @param[in]  aId          A pointer to a NULL-terminated string that is printed before the bytes.
+ * @param[in]  aBuf         A pointer to the buffer.
+ * @param[in]  aLength      Number of bytes to print.
+ *
+ */
+
+/**
+ * @def otDumpNoteMlr
+ *
+ * This method generates a memory dump with log level note and region Multicast Listener Registration (MLR).
+ *
+ * @param[in]  aId          A pointer to a NULL-terminated string that is printed before the bytes.
+ * @param[in]  aBuf         A pointer to the buffer.
+ * @param[in]  aLength      Number of bytes to print.
+ *
+ */
+
+/**
+ * @def otDumpInfoMlr
+ *
+ * This method generates a memory dump with log level info and region Multicast Listener Registration (MLR).
+ *
+ * @param[in]  aId          A pointer to a NULL-terminated string that is printed before the bytes.
+ * @param[in]  aBuf         A pointer to the buffer.
+ * @param[in]  aLength      Number of bytes to print.
+ *
+ */
+
+/**
+ * @def otDumpDebgMlr
+ *
+ * This method generates a memory dump with log level debug and region Multicast Listener Registration (MLR).
+ *
+ * @param[in]  aId          A pointer to a NULL-terminated string that is printed before the bytes.
+ * @param[in]  aBuf         A pointer to the buffer.
+ * @param[in]  aLength      Number of bytes to print.
+ *
+ */
+#if OPENTHREAD_CONFIG_LOG_MLR == 1
+#define otDumpCritMlr(aId, aBuf, aLength) otDumpCrit(OT_LOG_REGION_MLR, aId, aBuf, aLength)
+#define otDumpWarnMlr(aId, aBuf, aLength) otDumpWarn(OT_LOG_REGION_MLR, aId, aBuf, aLength)
+#define otDumpNoteMlr(aId, aBuf, aLength) otDumpNote(OT_LOG_REGION_MLR, aId, aBuf, aLength)
+#define otDumpInfoMlr(aId, aBuf, aLength) otDumpInfo(OT_LOG_REGION_MLR, aId, aBuf, aLength)
+#define otDumpDebgMlr(aId, aBuf, aLength) otDumpDebg(OT_LOG_REGION_MLR, aId, aBuf, aLength)
+#else
+#define otDumpCritMlr(aId, aBuf, aLength)
+#define otDumpWarnMlr(aId, aBuf, aLength)
+#define otDumpNoteMlr(aId, aBuf, aLength)
+#define otDumpInfoMlr(aId, aBuf, aLength)
+#define otDumpDebgMlr(aId, aBuf, aLength)
+#endif
+
+/**
  * @def otDumpCritIcmp
  *
  * This method generates a memory dump with log level debug and region ICMPv6.
diff --git a/src/core/config/logging.h b/src/core/config/logging.h
index 5d35108..c8d46ed 100644
--- a/src/core/config/logging.h
+++ b/src/core/config/logging.h
@@ -276,6 +276,18 @@
 #endif
 
 /**
+ * @def OPENTHREAD_CONFIG_LOG_MLR
+ *
+ * Note: available since Thread 1.2.
+ *
+ * Define to enable Multicast Listener Registration (MLR) region logging.
+ *
+ */
+#ifndef OPENTHREAD_CONFIG_LOG_MLR
+#define OPENTHREAD_CONFIG_LOG_MLR 1
+#endif
+
+/**
  * @def OPENTHREAD_CONFIG_LOG_PREPEND_LEVEL
  *
  * Define to prepend the log level to all log messages.
diff --git a/src/lib/spinel/spinel.h b/src/lib/spinel/spinel.h
index 0822795..915751f 100644
--- a/src/lib/spinel/spinel.h
+++ b/src/lib/spinel/spinel.h
@@ -644,6 +644,7 @@
     SPINEL_NCP_LOG_REGION_OT_CORE     = 15,
     SPINEL_NCP_LOG_REGION_OT_UTIL     = 16,
     SPINEL_NCP_LOG_REGION_OT_BBR      = 17,
+    SPINEL_NCP_LOG_REGION_OT_MLR      = 18,
 };
 
 enum
diff --git a/src/ncp/ncp_base.cpp b/src/ncp/ncp_base.cpp
index fe7dc6e..bd17952 100644
--- a/src/ncp/ncp_base.cpp
+++ b/src/ncp/ncp_base.cpp
@@ -612,6 +612,9 @@
     case OT_LOG_REGION_BBR:
         spinelLogRegion = SPINEL_NCP_LOG_REGION_OT_BBR;
         break;
+    case OT_LOG_REGION_MLR:
+        spinelLogRegion = SPINEL_NCP_LOG_REGION_OT_MLR;
+        break;
     }
 
     return spinelLogRegion;