storing test logs under /var/log/

Ganesh Pal ganesh1pal at gmail.com
Thu Dec 3 01:50:39 EST 2015


Hi Team ,


I would need few tips  from your past  experiences on  how  to store
the test logs


My requirement is to capture log under /var/log/  directory every time
the test is run .  The test will create one small log files  which are
around 1KB in size .


Here is how I plan to approach this , create directory based on
current timesamp and store the logs in it .


Sample code :

time_now = datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S') + "/"
LOG_DIR = ""  +  time_now

 try:
         retcode = os.makedirs(LOG_DIR)
         if retcode:
             raise Exception(
                     "Faild to create log directory. mkdir %s failed !!!"
                             % LOG_DIR)
    except Exception, e:
        sys.exit("Failed to create log directory...Exiting !!!")


1.  Do  I need to add the cleanup code  to remove the  log directory
say  /var/log/test_log/2015-11-25_04-07-48/   , because we might have
many more directories like this when test are run multiple times , Iam
avoiding because  the test will be  run

 2/3 times max and file sizes are also very small

2. Any better suggestion for my use case.


Regards,
Ganesh



More information about the Python-list mailing list