from logstash_formatter import LogstashFormatter
import logging
import os
import pdb
import sys
import traceback


def get_log_file_handler(path):
    handler = logging.FileHandler(path)
    handler.setFormatter(logging.Formatter(
        "%(asctime)s [%(levelname)s] -> %(message)s"))
    return handler


def get_json_log_handler(path, app_name):
    handler = logging.FileHandler(path)
    formatter = LogstashFormatter()
    formatter.defaults['@tags'] = ['collector', app_name]
    handler.setFormatter(formatter)
    return handler


def uncaught_exception_handler(*exc_info):
    text = "".join(traceback.format_exception(*exc_info))
    logging.error("Unhandled exception: %s", text)


def set_up_logging(app_name, log_level, logfile_path):
    sys.excepthook = uncaught_exception_handler
    logger = logging.getLogger()
    logger.setLevel(log_level)
    logger.addHandler(get_log_file_handler(
        os.path.join(logfile_path, 'collector.log')))
    logger.addHandler(get_json_log_handler(
        os.path.join(logfile_path, 'collector.log.json'), app_name))
    logger.info("{0} logging started".format(app_name))

@@ -339,19 +339,32 @@
 app_name
+, json_fields
 ):%0A
-
     hand
@@ -489,16 +489,59 @@
 p_name%5D%0A
+    formatter.defaults.update(json_fields)%0A
     hand
@@ -791,24 +791,42 @@
 logfile_path
+, json_fields=None
 ):%0A    sys.e
@@ -1127,16 +1127,24 @@
 .json'),
+%0A       
  app_nam
@@ -1144,16 +1144,72 @@
 app_name
+,%0A        json_fields=json_fields if json_fields else %7B%7D
 ))%0A    l

Add `json_fields` parameter to set_up_logging