Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Ganesh Pal Newsgroups: comp.lang.python Subject: storing test logs under /var/log/ Date: Thu, 3 Dec 2015 12:20:39 +0530 Lines: 43 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de beNaXMqfCMHS9B3fCOymowFQd1bfyDXdFxwUicMgAXxQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'cleanup': 0.07; 'subject:test': 0.07; 'exception,': 0.09; 'mkdir': 0.09; 'retcode': 0.09; '"/"': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:log': 0.16; 'subject:under': 0.16; 'case.': 0.18; 'directory.': 0.18; 'try:': 0.18; 'to:name :python-list@python.org': 0.20; 'message-id:@mail.gmail.com': 0.27; 'experiences': 0.27; 'raise': 0.29; 'subject:/': 0.30; 'code': 0.30; 'run': 0.33; 'avoiding': 0.33; 'file': 0.34; 'except': 0.34; 'add': 0.34; 'received:google.com': 0.35; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'say': 0.37; 'requirement': 0.37; 'suggestion': 0.37; 'received:209': 0.38; 'log': 0.38; 'files': 0.38; 'skip:o 20': 0.38; 'test': 0.39; 'to:addr:python.org': 0.40; 'your': 0.60; 'more': 0.63; 'sample': 0.63; 'times': 0.63; 'capture': 0.66; 'here': 0.66; 'skip:/ 30': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=6narA+Wo7hnz8hGTzZvCYY8GJjulKat+LbNJKOtFTG4=; b=QYGo60JuTWK8wlfKmiGGUj0USAq8MJYfdOFoKhTN9gQmtyFCjt0Bv5iEduejPmuRB9 clIUrtgiIRW3ldHx4sgYtw17kZ4HBpzHzHvr2pjAl3xsewj/kZd926IZdo+yuwDnJr3G ambThmIlToqPNgdvi8uJW7aqMokUfzTseM2SEPKM2wBftiRpGr/zWnl6h4DRynvpmmUG Y9qvpna2s56sSjcSolNjWDWUI6RVe/TtBMQr0t1deAjWeMxpFeEqVUUdmHyv4wGiWLoZ pk8Duqm55th6H1EzjDWGlZd9Q7rYJPsDQQG8BUzyycbnF08A4MQs7YRAe16603kyl2Bt OLzw== X-Received: by 10.112.8.104 with SMTP id q8mr4831449lba.115.1449125439401; Wed, 02 Dec 2015 22:50:39 -0800 (PST) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:99935 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