'''
Created on Sep 4, 2013

This class enables the software to log every action the users perform in the program. For now three distinctions are made, Info, warning or error
messages.

@author: Incalza Dario
'''
from datetime import datetime
from PyQt4.QtGui import QColor
from PyQt4 import QtGui,QtCore

class Logger(object):
   
    INFO=0x0
    WARNING=0x1
    ERROR=0x2
    '''
    A given console that is a text widget in the gui.
    '''
    def __init__(self,console):
        self.__console = console
        self.__console.setTextBackgroundColor(QColor(0,0,0))
    '''
    Log a text to inform the user of a certain IO action. Given : the text that needs to be displayed. A timestamp will be printed before the text.
    '''
    def log(self,level,text):
        if level==0x0:
            color = QColor(124, 252, 0)
            prefix=' - [Info]'
        elif level == 0x1:
            color = QColor(255,140,0)
            prefix=' - [Warning]'
        else:
            color = QColor(253,0,0)
            prefix=' - [Error]'
        self.__console.setTextColor(color)
        now = datetime.now()
        time = str(now.strftime("%H:%M"))
        self.__console.append(time+prefix+" >> "+text)
        QtGui.QApplication.processEvents()
    
    def clearLog(self):
        self.__console.clear()
    
    def saveLog(self):
        filename = "biasstress_log_"+str(datetime.now().strftime("%d%m%y-%H%M"))
        path = QtGui.QFileDialog.getSaveFileName(None, QtCore.QString('Open file'), QtCore.QString(filename),".txt")
        if path=='':
            return
        text_file = open(path, "w")
        text_file.write(self.__console.toPlainText())
        text_file.close()
        self.log(Logger.INFO, "Log saved succesfully in "+path)
5be55d00fdbeb6916e455342faadf6514aa39987
<mask token>


class Logger(object):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    def log(self, level, text):
        if level == 0:
            color = QColor(124, 252, 0)
            prefix = ' - [Info]'
        elif level == 1:
            color = QColor(255, 140, 0)
            prefix = ' - [Warning]'
        else:
            color = QColor(253, 0, 0)
            prefix = ' - [Error]'
        self.__console.setTextColor(color)
        now = datetime.now()
        time = str(now.strftime('%H:%M'))
        self.__console.append(time + prefix + ' >> ' + text)
        QtGui.QApplication.processEvents()

    def clearLog(self):
        self.__console.clear()
    <mask token>

<mask token>


class Logger(object):
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    def __init__(self, console):
        self.__console = console
        self.__console.setTextBackgroundColor(QColor(0, 0, 0))
    <mask token>

    def log(self, level, text):
        if level == 0:
            color = QColor(124, 252, 0)
            prefix = ' - [Info]'
        elif level == 1:
            color = QColor(255, 140, 0)
            prefix = ' - [Warning]'
        else:
            color = QColor(253, 0, 0)
            prefix = ' - [Error]'
        self.__console.setTextColor(color)
        now = datetime.now()
        time = str(now.strftime('%H:%M'))
        self.__console.append(time + prefix + ' >> ' + text)
        QtGui.QApplication.processEvents()

    def clearLog(self):
        self.__console.clear()

    def saveLog(self):
        filename = 'biasstress_log_' + str(datetime.now().strftime(
            '%d%m%y-%H%M'))
        path = QtGui.QFileDialog.getSaveFileName(None, QtCore.QString(
            'Open file'), QtCore.QString(filename), '.txt')
        if path == '':
            return
        text_file = open(path, 'w')
        text_file.write(self.__console.toPlainText())
        text_file.close()
        self.log(Logger.INFO, 'Log saved succesfully in ' + path)

<mask token>


class Logger(object):
    INFO = 0
    WARNING = 1
    ERROR = 2
    """
    A given console that is a text widget in the gui.
    """

    def __init__(self, console):
        self.__console = console
        self.__console.setTextBackgroundColor(QColor(0, 0, 0))
    """
    Log a text to inform the user of a certain IO action. Given : the text that needs to be displayed. A timestamp will be printed before the text.
    """

    def log(self, level, text):
        if level == 0:
            color = QColor(124, 252, 0)
            prefix = ' - [Info]'
        elif level == 1:
            color = QColor(255, 140, 0)
            prefix = ' - [Warning]'
        else:
            color = QColor(253, 0, 0)
            prefix = ' - [Error]'
        self.__console.setTextColor(color)
        now = datetime.now()
        time = str(now.strftime('%H:%M'))
        self.__console.append(time + prefix + ' >> ' + text)
        QtGui.QApplication.processEvents()

    def clearLog(self):
        self.__console.clear()

    def saveLog(self):
        filename = 'biasstress_log_' + str(datetime.now().strftime(
            '%d%m%y-%H%M'))
        path = QtGui.QFileDialog.getSaveFileName(None, QtCore.QString(
            'Open file'), QtCore.QString(filename), '.txt')
        if path == '':
            return
        text_file = open(path, 'w')
        text_file.write(self.__console.toPlainText())
        text_file.close()
        self.log(Logger.INFO, 'Log saved succesfully in ' + path)

<mask token>
from datetime import datetime
from PyQt4.QtGui import QColor
from PyQt4 import QtGui, QtCore


class Logger(object):
    INFO = 0
    WARNING = 1
    ERROR = 2
    """
    A given console that is a text widget in the gui.
    """

    def __init__(self, console):
        self.__console = console
        self.__console.setTextBackgroundColor(QColor(0, 0, 0))
    """
    Log a text to inform the user of a certain IO action. Given : the text that needs to be displayed. A timestamp will be printed before the text.
    """

    def log(self, level, text):
        if level == 0:
            color = QColor(124, 252, 0)
            prefix = ' - [Info]'
        elif level == 1:
            color = QColor(255, 140, 0)
            prefix = ' - [Warning]'
        else:
            color = QColor(253, 0, 0)
            prefix = ' - [Error]'
        self.__console.setTextColor(color)
        now = datetime.now()
        time = str(now.strftime('%H:%M'))
        self.__console.append(time + prefix + ' >> ' + text)
        QtGui.QApplication.processEvents()

    def clearLog(self):
        self.__console.clear()

    def saveLog(self):
        filename = 'biasstress_log_' + str(datetime.now().strftime(
            '%d%m%y-%H%M'))
        path = QtGui.QFileDialog.getSaveFileName(None, QtCore.QString(
            'Open file'), QtCore.QString(filename), '.txt')
        if path == '':
            return
        text_file = open(path, 'w')
        text_file.write(self.__console.toPlainText())
        text_file.close()
        self.log(Logger.INFO, 'Log saved succesfully in ' + path)

'''
Created on Sep 4, 2013

This class enables the software to log every action the users perform in the program. For now three distinctions are made, Info, warning or error
messages.

@author: Incalza Dario
'''
from datetime import datetime
from PyQt4.QtGui import QColor
from PyQt4 import QtGui,QtCore

class Logger(object):
   
    INFO=0x0
    WARNING=0x1
    ERROR=0x2
    '''
    A given console that is a text widget in the gui.
    '''
    def __init__(self,console):
        self.__console = console
        self.__console.setTextBackgroundColor(QColor(0,0,0))
    '''
    Log a text to inform the user of a certain IO action. Given : the text that needs to be displayed. A timestamp will be printed before the text.
    '''
    def log(self,level,text):
        if level==0x0:
            color = QColor(124, 252, 0)
            prefix=' - [Info]'
        elif level == 0x1:
            color = QColor(255,140,0)
            prefix=' - [Warning]'
        else:
            color = QColor(253,0,0)
            prefix=' - [Error]'
        self.__console.setTextColor(color)
        now = datetime.now()
        time = str(now.strftime("%H:%M"))
        self.__console.append(time+prefix+" >> "+text)
        QtGui.QApplication.processEvents()
    
    def clearLog(self):
        self.__console.clear()
    
    def saveLog(self):
        filename = "biasstress_log_"+str(datetime.now().strftime("%d%m%y-%H%M"))
        path = QtGui.QFileDialog.getSaveFileName(None, QtCore.QString('Open file'), QtCore.QString(filename),".txt")
        if path=='':
            return
        text_file = open(path, "w")
        text_file.write(self.__console.toPlainText())
        text_file.close()
        self.log(Logger.INFO, "Log saved succesfully in "+path)