Skip to content

Commit

Permalink
added log method in class Generator for storing information about com…
Browse files Browse the repository at this point in the history
…mand line arguments, date, time, user and hostname in generatemc.log
  • Loading branch information
Michał authored and Michal Szczerba committed Aug 26, 2017
1 parent f480569 commit dbd7447
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions mcpartools/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
import logging
import shutil
import time
import sys
import getpass
import socket

from mcpartools.mcengine.common import EngineDiscover
from mcpartools.scheduler.common import SchedulerDiscover
Expand Down Expand Up @@ -139,6 +142,9 @@ def run(self):
# make symlinks to external files found
self.symlink_external_files()

# store information about command line arguments, date, time, user and hostname into generatemc.log
self.log()

# save logs
self.save_logs()

Expand Down Expand Up @@ -226,3 +232,12 @@ def symlink_external_files(self):

def save_logs(self):
pass

def log(self):
with open(os.path.join(self.main_dir, "generatemc.log"), 'a') as LOG_FILE:
for arg in sys.argv:
LOG_FILE.write(arg + " ")
LOG_FILE.write("\n")
LOG_FILE.write(time.strftime("%Y-%m-%d %H:%M:%S\n"))
LOG_FILE.write(getpass.getuser() + '@' + socket.gethostname() + "\n")

0 comments on commit dbd7447

Please sign in to comment.