
import stathat
import time
import syslog

def action(**kwargs):
    ''' This method is called to action a reaction '''
    updateStathat(kwargs['jdata'])
    return True


def updateStathat(jdata):
    ''' This method will be called to update a stathat Statistic '''
    ez_key = jdata['time_tracking']['ez_key']
    stat_name = "[%s] End to End Monitor transaction time" % jdata[
        'time_tracking']['env']
    value = time.time() - jdata['time_tracking']['control']
    stathat.ez_value(ez_key, stat_name, value)
    line = "timetracker: Sent stat to StatHat for %s" % jdata['cid']
    syslog.syslog(syslog.LOG_INFO, line)


import stathat
import time

def action(**kwargs):
    ''' This method is called to action a reaction '''
    logger = kwargs['logger']
    updateStathat(kwargs['jdata'], logger)
    return True


def updateStathat(jdata, logger):
    ''' This method will be called to update a stathat Statistic '''
    ez_key = jdata['time_tracking']['ez_key']
    stat_name = "[%s] End to End Monitor transaction time" % jdata[
        'time_tracking']['env']
    value = time.time() - jdata['time_tracking']['control']
    stathat.ez_value(ez_key, stat_name, value)
    line = "timetracker: Sent stat to StatHat for %s" % jdata['cid']
    logger.info(line)

Convert reactions syslog to logger: timetracking
Convert reactions syslog to logger: timetracking

  
  import stathat
  import time
- import syslog
  
  def action(**kwargs):
      ''' This method is called to action a reaction '''
+     logger = kwargs['logger']
-     updateStathat(kwargs['jdata'])
+     updateStathat(kwargs['jdata'], logger)
      return True
  
  
- def updateStathat(jdata):
+ def updateStathat(jdata, logger):
      ''' This method will be called to update a stathat Statistic '''
      ez_key = jdata['time_tracking']['ez_key']
      stat_name = "[%s] End to End Monitor transaction time" % jdata[
          'time_tracking']['env']
      value = time.time() - jdata['time_tracking']['control']
      stathat.ez_value(ez_key, stat_name, value)
      line = "timetracker: Sent stat to StatHat for %s" % jdata['cid']
-     syslog.syslog(syslog.LOG_INFO, line)
+     logger.info(line)
  
Convert reactions syslog to logger: timetracking
## Code Before:

import stathat
import time
import syslog

def action(**kwargs):
    ''' This method is called to action a reaction '''
    updateStathat(kwargs['jdata'])
    return True


def updateStathat(jdata):
    ''' This method will be called to update a stathat Statistic '''
    ez_key = jdata['time_tracking']['ez_key']
    stat_name = "[%s] End to End Monitor transaction time" % jdata[
        'time_tracking']['env']
    value = time.time() - jdata['time_tracking']['control']
    stathat.ez_value(ez_key, stat_name, value)
    line = "timetracker: Sent stat to StatHat for %s" % jdata['cid']
    syslog.syslog(syslog.LOG_INFO, line)

## Instruction:
Convert reactions syslog to logger: timetracking
## Code After:

import stathat
import time

def action(**kwargs):
    ''' This method is called to action a reaction '''
    logger = kwargs['logger']
    updateStathat(kwargs['jdata'], logger)
    return True


def updateStathat(jdata, logger):
    ''' This method will be called to update a stathat Statistic '''
    ez_key = jdata['time_tracking']['ez_key']
    stat_name = "[%s] End to End Monitor transaction time" % jdata[
        'time_tracking']['env']
    value = time.time() - jdata['time_tracking']['control']
    stathat.ez_value(ez_key, stat_name, value)
    line = "timetracker: Sent stat to StatHat for %s" % jdata['cid']
    logger.info(line)
