Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #99935

storing test logs under /var/log/

From Ganesh Pal <ganesh1pal@gmail.com>
Newsgroups comp.lang.python
Subject storing test logs under /var/log/
Date 2015-12-03 12:20 +0530
Message-ID <mailman.158.1449125446.14615.python-list@python.org> (permalink)

Show all headers | View raw


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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

storing test logs under /var/log/ Ganesh Pal <ganesh1pal@gmail.com> - 2015-12-03 12:20 +0530

csiph-web