source: branches/testScripts/NBlogMessages.py @ 746

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

Added ability to retrieve history of log messages

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