Added start record to fluentd and passing host ip to initializer
Change-Id: I048a6ad981e7a69c461ccd7e9199a0abbf09b82c
This commit is contained in:
parent
3168f4f696
commit
18a0f788c2
@ -32,8 +32,10 @@ class FluentLogHandler(logging.Handler):
|
||||
logging.Handler.__init__(self)
|
||||
self.tag = tag
|
||||
self.formatter = logging.Formatter('%(message)s')
|
||||
self.sender = sender.FluentSender(self.tag, port=fluentd_port)
|
||||
self.start_new_run()
|
||||
self.sender = sender.FluentSender(self.tag, host=fluentd_ip, port=fluentd_port)
|
||||
self.runlogdate = 0
|
||||
self.__warning_counter = 0
|
||||
self.__error_counter = 0
|
||||
|
||||
def start_new_run(self):
|
||||
'''Delimitate a new run in the stream of records with a new timestamp
|
||||
@ -42,6 +44,8 @@ class FluentLogHandler(logging.Handler):
|
||||
# reset counters
|
||||
self.__warning_counter = 0
|
||||
self.__error_counter = 0
|
||||
# send start record
|
||||
self.__send_start_record()
|
||||
|
||||
def emit(self, record):
|
||||
data = {
|
||||
@ -52,6 +56,18 @@ class FluentLogHandler(logging.Handler):
|
||||
self.__update_stats(record.levelno)
|
||||
self.sender.emit(None, data)
|
||||
|
||||
# send START record for each run
|
||||
def __send_start_record(self):
|
||||
data = {
|
||||
"runlogdate": self.runlogdate,
|
||||
"loglevel": "START",
|
||||
"message": "VMTP run is started",
|
||||
"numloglevel": 0,
|
||||
"numerrors": 0,
|
||||
"numwarnings": 0
|
||||
}
|
||||
self.sender.emit(None, data)
|
||||
|
||||
# send stats related to the current run and reset state for a new run
|
||||
def send_run_summary(self, run_summary_required):
|
||||
if run_summary_required or self.__get_highest_level() == logging.ERROR:
|
||||
|
@ -464,6 +464,8 @@ class VmtpTest(object):
|
||||
# take a snapshot of the current time for this new run
|
||||
# so that all subsequent logs can relate to this run
|
||||
fluent_logger.start_new_run()
|
||||
params = ' '.join(str(e) for e in sys.argv[1:])
|
||||
LOG.info(params)
|
||||
try:
|
||||
self.setup()
|
||||
self.measure_vm_flows()
|
||||
|
Loading…
x
Reference in New Issue
Block a user