source: branches/testScripts/NBlogMessages.py @ 668

Last change on this file since 668 was 668, checked in by stefan, 13 years ago

allow to let messages go into a logfile instead of stdout

File size: 701 bytes
Line 
1#! /usr/bin/env python
2
3import time
4import NBuserConfig
5
6#TODO: one could open the logfile once in the beginning, set it to sys.stdout, flush after each message, and close it finally
7
8#------------------------------------------------------------------------
9# Function to write log messages
10#------------------------------------------------------------------------
11def writeMessage( msg ) :
12  logMsg = time.ctime(time.time())+': '
13  logMsg += msg
14  if len(NBuserConfig.LOGFILE) == 0 or NBuserConfig.LOGFILE.isspace() :
15    print logMsg
16  else :
17    logfile=open(NBuserConfig.NIGHTLY_BUILD_ROOT_DIR+'/'+NBuserConfig.LOGFILE, 'a')
18    logfile.write(logMsg+'\n')
19#    logfile.flush()
20    logfile.close()
Note: See TracBrowser for help on using the repository browser.