source: branches/testScripts/NBlogMessages.py @ 761

Last change on this file since 761 was 746, checked in by jpfasano, 12 years ago

Added ability to retrieve history of log messages

  • Property svn:eol-style set to native
File size: 1.4 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
13#TODO: one could open the logfile once in the beginning, set it to sys.stdout, flush after each message, and close it finally
14
15LOG_MESSAGES=''
16FULL_LOG_MESSAGES=''
17
18def clearMessages():
19  global LOG_MESSAGES
20  global FULL_LOG_MESSAGES
21  FULL_LOG_MESSAGES+=LOG_MESSAGES
22  LOG_MESSAGES=''
23
24def getMessages():
25  global LOG_MESSAGES
26  return LOG_MESSAGES
27
28
29def getAllMessages():
30  global LOG_MESSAGES
31  global FULL_LOG_MESSAGES
32  retVal = FULL_LOG_MESSAGES+LOG_MESSAGES
33  return retVal
34
35
36#------------------------------------------------------------------------
37# Function to write log messages
38#------------------------------------------------------------------------
39def writeMessage( msg ) :
40  global LOG_MESSAGES
41  logMsg = time.ctime(time.time())+': '
42  logMsg += msg
43  LOG_MESSAGES+=logMsg+'\n'
44  if LOGPRINT :
45    print logMsg
46  if len(LOGFILE) > 0 and not LOGFILE.isspace() :
47    logfile=open(NIGHTLY_BUILD_ROOT_DIR+'/'+LOGFILE, 'a')
48    logfile.write(logMsg+'\n')
49#    logfile.flush()
50    logfile.close()
Note: See TracBrowser for help on using the repository browser.