Package: greendeck-logging
Greendeck-Logging:![logging]Install from piphttps://pypi.org/project/greendeck-logging/pip install greendeck-loggingThis library can be used for save the critical log, message, info data for your internal services in elasticsearch and create a nice visualization through kibana.
For creating  visualization in kibana you can refer thisdocumentationif you don't have elasticsearch and kibana you can refer thisblogHow to use?import the libraryfrom greendeck_logging import GdLogging
from greendeck_logging import GdLoggingStackThere are Two ways to save the log data, by bulk (GdLoggingStack) and one by one (GdLogging)If you want to save the log in memory as stack and send data after process completes, useGdLoggingStack. It saves the log messages in stack and send to elastic search on calling push method.Variables to connect elasticsearch to store the log dataLOG_ECS_HOST =  < YOUR_LOG_ECS_HOST >
LOG_ECS_INDEX = < LOG_ECS_INDEX >
LOG_ECS_TYPE = < LOG_ECS_TYPE >
service_name = < service_name >if elasticsearch requires username and password to connect, provide in LOG_ECS_HOST in a standard format likehttps://username:password@elasticsearch_host:port_noEg :https://admin:admin123@127.0.0.0:9200/Some Default Values are :LOG_ECS_INDEX = gdlogging,  LOG_ECS_TYPE  = '_doc'if you want save data in other index name instead of gdlogging , assignLOG_ECS_INDEX = "your index name"GdLoggingStack :Send the bulk log data to elasticsearchfrom greendeck_logging import GdLoggingStack
gdl_stack = GdLoggingStack(LOG_ECS_HOST = LOG_ECS_HOST,
                          service_name = service_name  
                          LOG_ECS_INDEX = "gdlogging",
                          LOG_ECS_TYPE = "_doc",
                          )**default value:
LOG_ECS_INDEX = 'gdlogging',
LOG_ECS_TYPE = '_doc',**LOG_ECS_TYPE and SERVICE_NAME are required fieldMethods and their functionalityThere are following function for capturing the eventsFor capturing Error message and info of the error due to which occur ,gdl_stack.error("your message", info = {}, value = 1)default, value = 1, info = {} # info can be dictionaryTo save Debug message and send the object as infogdl_stack.debug("your debug message", info = {}, value = 1)To increament the response status of the services like 200, 404 etcgdl_stack.counter_message(message, info = {}, value = 1)default, value = 1To increment the  message  for a particularwebsite( It can be your unique identifier depending on requirement )gdl_stack.counter_website(website, message, info = {}, value = 1)default, value = 1clear the stackgdl_stack.clear()total element in stackgdl_stack.count()show the first element in the stackgdl_stack.show_one()show all elements in the stackgdl_stack.show()push all elements to elastic searchgdl_stack.push()** Don't forget to push the element to elastic search at end of your stack, usegdl_stack.push()for update the data in elastic searchGdLogging: It updates one element at a timefrom greendeck_logging import GdLogging
gdl = GdLogging(LOG_ECS_HOST = LOG_ECS_HOST,
                          service_name = service_name  
                          LOG_ECS_INDEX = "gdlogging",
                          LOG_ECS_TYPE = "_doc",
                          )**default value:
LOG_ECS_INDEX = 'gdlogging',
LOG_ECS_TYPE = '_doc',Usage and functionalityThere are following function for capturing the eventsFor capturing Error message and info due to which occurgdl.error("your message", info = {}, value = 1)default, value = 1 , info = {}For capturign Debug messagegdl.debug("your message", info = {}, value = 1)default, value = 1To increament the response status of the services like 200, 404 etcgdl.counter_message(message, info = {}, value = 1)default, value = 1To increment the  message  for a particularwebsite( It can be your unique identifier depending on requirement )gdl.counter_website(website, message, info = {}, value = 1)default, value = 1Example of the object which will save into the elastic search"_index" : "gd_logging",
        "_type" : "_doc",
        "_id" : "0TASCGsBFBI3I7B8680B",
        "_score" : 2.3312538,
        "_source" : {
          "service_name" : "class_service",
          "log_type" : "info",
          "created_at" : "2019-05-30T14:59:45.452035",
          "meta" : {
            "file_name" : "service.py",
            "user_name" : "user",
            "system_name" : "user-300-15ISK",
            "os_name" : "Linux"
          },
          "counter_status" : {  
            "message" : "response status",
            "counter_type" : "status",
            "counter_name" : "201",
            "counter_value" : 1
          }
        }
      }