fixed timestamps not matching the transaction when saving to log file
This commit is contained in:
parent
ac603bed07
commit
490d21acbd
2 changed files with 3 additions and 3 deletions
2
logs.py
2
logs.py
|
|
@ -20,7 +20,7 @@ def set_channel_logger(channel_name, level=logging.INFO):
|
|||
os.makedirs("{}/logs/".format(os.getenv("DATA_FOLDER")), exist_ok=True)
|
||||
log_file = "{}/logs/{}.log".format(os.getenv("DATA_FOLDER"), channel_name)
|
||||
handler = TimedRotatingFileHandler(log_file, when="midnight", interval=1, utc=True)
|
||||
handler.setFormatter(logging.Formatter("[%(asctime)s] %(message)s", "%Y-%m-%d %H:%M:%S"))
|
||||
handler.setFormatter(logging.Formatter("%(message)s"))
|
||||
logger = logging.getLogger(channel_name)
|
||||
logger.setLevel(level)
|
||||
logger.addHandler(handler)
|
||||
|
|
|
|||
4
main.py
4
main.py
|
|
@ -78,9 +78,9 @@ def output_line(event):
|
|||
raise Exception("Could not get block {}".format(block_number))
|
||||
|
||||
# log the message and output to console
|
||||
message = "{}:{} {}".format(decoded_data[0]['args']['Soul'], decoded_data[0]['args']['Aura'], decoded_data[0]['args']['LogLine'])
|
||||
log_message(os.getenv('CHANNEL_NAME'), message)
|
||||
timestamp = datetime.fromtimestamp(block_cache[block_number]['timestamp'], tz=timezone.utc)
|
||||
message = "{}:{} {}".format(decoded_data[0]['args']['Soul'], decoded_data[0]['args']['Aura'], decoded_data[0]['args']['LogLine'])
|
||||
log_message(os.getenv('CHANNEL_NAME'), "[{}] {}".format(timestamp.strftime("%Y-%m-%d %H:%M:%S"), message))
|
||||
print("[{}] {}".format(timestamp.strftime("%Y-%m-%d %H:%M:%S"), message if os.getenv('SHOW_AURA_AND_SOUL') != '0' else decoded_data[0]['args']['LogLine']))
|
||||
|
||||
# save latest block number
|
||||
|
|
|
|||
Loading…
Reference in a new issue