Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #99935 > unrolled thread
| Started by | Ganesh Pal <ganesh1pal@gmail.com> |
|---|---|
| First post | 2015-12-03 12:20 +0530 |
| Last post | 2015-12-03 12:20 +0530 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
storing test logs under /var/log/ Ganesh Pal <ganesh1pal@gmail.com> - 2015-12-03 12:20 +0530
| From | Ganesh Pal <ganesh1pal@gmail.com> |
|---|---|
| Date | 2015-12-03 12:20 +0530 |
| Subject | storing test logs under /var/log/ |
| Message-ID | <mailman.158.1449125446.14615.python-list@python.org> |
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 top | Article view | comp.lang.python
csiph-web