source: branches/testScripts/NBlogMessages.py @ 771

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

make the logfile object a global variable

  • Property svn:eol-style set to native
File size: 1.3 KB
Line 
1#! /usr/bin/env python
2
3#------------------------------------------------------------------------
4# This file is distributed under the Common Public License.
5# It is part of the BuildTools project in COIN-OR (www.coin-or.org)
6#------------------------------------------------------------------------
7
8import time
9
10execfile('NBuserParametersDefault.py')
11execfile('NBuserParameters.py')
12
13LOG_MESSAGES=''
14FULL_LOG_MESSAGES=''
15logfile=''
16
17def clearMessages():
18  global LOG_MESSAGES
19  global FULL_LOG_MESSAGES
20  FULL_LOG_MESSAGES+=LOG_MESSAGES
21  LOG_MESSAGES=''
22
23def getMessages():
24  global LOG_MESSAGES
25  return LOG_MESSAGES
26
27
28def getAllMessages():
29  global LOG_MESSAGES
30  global FULL_LOG_MESSAGES
31  retVal = FULL_LOG_MESSAGES+LOG_MESSAGES
32  return retVal
33
34def openLogFile():
35  global logfile
36  logfile=open(NIGHTLY_BUILD_ROOT_DIR+'/'+LOGFILE, 'a')
37   
38def closeLogFile():
39  global logfile
40  logfile.close()
41
42#------------------------------------------------------------------------
43# Function to write log messages
44#------------------------------------------------------------------------
45def writeMessage( msg ) :
46  global LOG_MESSAGES
47  logMsg = time.ctime(time.time())+': '
48  logMsg += msg
49  LOG_MESSAGES+=logMsg+'\n'
50  if LOGPRINT :
51    print logMsg
52  if len(LOGFILE) > 0 and not LOGFILE.isspace() :
53    global logfile
54    logfile.write(logMsg+'\n')
55    logfile.flush()
Note: See TracBrowser for help on using the repository browser.