Add log formatting option and dynamic Log-Level change Implement MDC Log entry format...
[com/pylog.git] / docs / developer-guide.rst
index 89aa92a..33f9735 100644 (file)
@@ -66,7 +66,7 @@ out of the process.
 
 *Example log output*
 
-`{"ts": 1559285893047, "crit": "INFO", "id": "myprog", "mdc": {"second key":"other value","mykey":"keyval"}, "msg": "Hello world!"}`
+`{"ts": 1603103945651, "crit": "ERROR", "id": "test.py", "mdc": {"SYSTEM_NAME": "Cloud-Space", "HOST_NAME": "master", "SERVICE_NAME": "TestApp", "CONTAINER_NAME": "Container-101", "POD_NAME": "POD-101"}, "msg": "Hello World!"}`
 
 Install
 -------
@@ -93,6 +93,7 @@ The library can be used in two ways shown below.
 
  ```python
    import mdclogpy
+   mdclogpy.mdclog_format_init(configmap_monitor=True) 
    mdclogpy.error("This is an error log")
  ```
 
@@ -103,11 +104,16 @@ The library can be used in two ways shown below.
  ```python
    from mdclogpy import Logger
    my_logger = Logger()
+   my_logger.mdclog_format_init(configmap_monitor=True)
    my_logger.error("This is an error log")
  ```
 
 A program can create several logger instances.
 
+mdclog_format_init() Adds the MDC log format with HostName, PodName, ContainerName, ServiceName,PID,CallbackNotifyforLogFieldChange
+
+Pass configmap_monitor = False in mdclog_format_init() function to stop dynamic log level change based on configmap.
+
 Logging Levels
 --------------
 .. code:: bash
@@ -165,6 +171,21 @@ Pylog API's
  def clean_mdc(self):
 
 
+7. Initialise Sep Logging format: 
+
+This api Initialzes mdclog print format using MDC Dictionary by extracting the environment variables in the calling process for “SYSTEM_NAME”, “HOST_NAME”, “SERVICE_NAME”, “CONTAINER_NAME”, “POD_NAME” & “CONFIG_MAP_NAME” mapped to HostName, ServiceName, ContainerName, Podname and Configuration-file-name of the services respectively.
+
+
+.. code:: bash
+
+ def mdclog_format_init(configmap_monitor=False):
+
+        Keyword arguments:
+        configmap_monitor -- Enables/Disables Dynamic log level change based on configmap
+                          -- Boolean values True/False can be passed as per requirement.
+
+
+
 License
 -------