Esempio n. 1
0
  def test_00setShowHeaders(self):
    """
    Set the headers
    """
    gLogger.showHeaders(False)
    gLogger.notice('message')

    oldgLogger.showHeaders(False)
    oldgLogger.notice('message')

    self.assertEqual("message \n", self.buffer.getvalue())
    self.assertEqual(self.buffer.getvalue().replace(" ", ""), self.oldbuffer.getvalue().replace(" ", ""))
    self.buffer.truncate(0)
    self.oldbuffer.truncate(0)

    gLogger.showHeaders(True)
    gLogger.notice('message')

    oldgLogger.showHeaders(True)
    oldgLogger.notice('message')

    logstring1 = cleaningLog(self.buffer.getvalue())
    logstring2 = cleaningLog(self.oldbuffer.getvalue())

    self.assertEqual("UTCFrameworkNOTICE:message\n", logstring1)
    self.assertEqual(logstring1, logstring2)
    self.buffer.truncate(0)
    self.oldbuffer.truncate(0)
Esempio n. 2
0
  def test_00setShowHeaders(self):
    """
    Set the headers
    """
    gLogger.showHeaders(False)
    gLogger.notice('message', 'varmessage')

    oldgLogger.showHeaders(False)
    oldgLogger.notice('message', 'varmessage')

    self.assertEqual("message varmessage\n", self.buffer.getvalue())
    self.assertEqual(self.buffer.getvalue(), self.oldbuffer.getvalue())
    self.buffer.truncate(0)
    self.oldbuffer.truncate(0)

    gLogger.showHeaders(True)
    gLogger.notice('message')

    oldgLogger.showHeaders(True)
    oldgLogger.notice('message')

    logstring1 = cleaningLog(self.buffer.getvalue())
    logstring2 = cleaningLog(self.oldbuffer.getvalue())

    self.assertEqual("UTCFrameworkNOTICE:message\n", logstring1)
    self.assertEqual(logstring1, logstring2)
    self.buffer.truncate(0)
    self.oldbuffer.truncate(0)
Esempio n. 3
0
  def test_04SubLogShowHeadersChange(self):
    """
    Create a sublogger and show that its Header option follow the change of its parent Header option.
    """
    sublog = gLogger.getSubLogger('sublog2')
    sublog.setLevel('notice')
    sublog.registerBackend('file', {'FileName': self.filename})
    # Empty the buffer to remove the Object Loader log message "trying to load..."
    self.buffer.truncate(0)
    gLogger.showHeaders(False)

    sublog.notice("message")
    with open(self.filename) as file:
      message = file.read()

    self.assertEqual(message, "message \n")
    self.assertEqual(self.buffer.getvalue(), "message \n")
Esempio n. 4
0
  def test_04SubLogShowHeadersChange(self):
    """
    Create a sublogger and show that its Header option follow the change of its parent Header option.
    """
    sublog = gLogger.getSubLogger('sublog2')
    sublog.setLevel('notice')
    sublog.registerBackend('file', {'FileName': self.filename})
    # Empty the buffer to remove the Object Loader log message "trying to load..."
    self.buffer.truncate(0)
    gLogger.showHeaders(False)

    sublog.notice("message")
    with open(self.filename) as file:
      message = file.read()

    self.assertEqual(message, "message\n")
    self.assertEqual(self.buffer.getvalue(), "message\n")
Esempio n. 5
0
  def test_06setSubLoggLoggerShowHeadersInverse(self):
    """
    Create a sublogger, set the Header option of the gLogger and its Header option. 
    Show that the gLogger Header option do not follow the change of its child Header option.
    """
    sublog = gLogger.getSubLogger('sublog4')
    sublog.setLevel('notice')
    sublog.registerBackend('file', {'FileName': self.filename})
    # Empty the buffer to remove the Object Loader log message "trying to load..."
    self.buffer.truncate(0)
    gLogger.showHeaders(True)
    sublog.showHeaders(False)

    sublog.notice("message")
    with open(self.filename) as file:
      message = file.read()

    self.assertEqual(message, "message \n")
    logstring1 = cleaningLog(self.buffer.getvalue())
    self.assertEqual(logstring1, "UTCFramework/sublog4NOTICE:message\n")
Esempio n. 6
0
  def test_06setSubLoggLoggerShowHeadersInverse(self):
    """
    Create a sublogger, set the Header option of the gLogger and its Header option. 
    Show that the gLogger Header option do not follow the change of its child Header option.
    """
    sublog = gLogger.getSubLogger('sublog4')
    sublog.setLevel('notice')
    sublog.registerBackend('file', {'FileName': self.filename})
    # Empty the buffer to remove the Object Loader log message "trying to load..."
    self.buffer.truncate(0)
    gLogger.showHeaders(True)
    sublog.showHeaders(False)

    sublog.notice("message")
    with open(self.filename) as file:
      message = file.read()

    self.assertEqual(message, "message\n")
    logstring1 = cleaningLog(self.buffer.getvalue())
    self.assertEqual(logstring1, "UTCFramework/sublog4NOTICE:message\n")
Esempio n. 7
0
  def test_10gLoggerShowHeadersChange2Times(self):
    """
    Create a sublogger with a file backend and change the Header option of gLogger 2 times
    in order to verify the propagation.
    """
    sublog = gLogger.getSubLogger('sublog8')
    sublog.registerBackends(['file'], {'FileName': self.filename})
    # Empty the buffer to remove the Object Loader log message "trying to load..."
    self.buffer.truncate(0)
    gLogger.showHeaders(False)
    sublog.notice("message")
    
    with open(self.filename) as file:
      message = file.read()

    self.assertEqual("message \n", message)

    gLogger.showHeaders(True)
    sublog.notice("message")
    
    with open(self.filename) as file:
      message = file.read()
    self.assertIn("UTC Framework/sublog8 NOTICE: message \n", message)
Esempio n. 8
0
  def test_10gLoggerShowHeadersChange2Times(self):
    """
    Create a sublogger with a file backend and change the Header option of gLogger 2 times
    in order to verify the propagation.
    """
    sublog = gLogger.getSubLogger('sublog8')
    sublog.registerBackends(['file'], {'FileName': self.filename})
    # Empty the buffer to remove the Object Loader log message "trying to load..."
    self.buffer.truncate(0)
    gLogger.showHeaders(False)
    sublog.notice("message")
    
    with open(self.filename) as file:
      message = file.read()

    self.assertEqual("message\n", message)

    gLogger.showHeaders(True)
    sublog.notice("message")
    
    with open(self.filename) as file:
      message = file.read()
    self.assertIn("UTC Framework/sublog8 NOTICE: message\n", message)
Esempio n. 9
0
  def test_02setShowThreadIDsHeaders(self):
    """
    Create a subsubsublogger and create a logrecord
    """
    gLogger.showHeaders(False)
    gLogger.showThreadIDs(False)
    gLogger.notice('message')

    oldgLogger.showHeaders(False)
    oldgLogger.showThreadIDs(False)
    oldgLogger.notice('message')

    self.assertEqual("message \n", self.buffer.getvalue())
    self.assertEqual(self.buffer.getvalue().replace(" ", ""), self.oldbuffer.getvalue().replace(" ", ""))
    self.buffer.truncate(0)
    self.oldbuffer.truncate(0)

    gLogger.showHeaders(False)
    gLogger.showThreadIDs(True)
    gLogger.notice('message')

    oldgLogger.showHeaders(False)
    oldgLogger.showThreadIDs(True)
    oldgLogger.notice('message')

    self.assertEqual("message \n", self.buffer.getvalue())
    self.assertEqual(self.buffer.getvalue().replace(" ", ""), self.oldbuffer.getvalue().replace(" ", ""))
    self.buffer.truncate(0)
    self.oldbuffer.truncate(0)

    gLogger.showHeaders(True)
    gLogger.showThreadIDs(False)
    gLogger.notice('message')

    oldgLogger.showHeaders(True)
    oldgLogger.showThreadIDs(False)
    oldgLogger.notice('message')

    logstring1 = cleaningLog(self.buffer.getvalue())
    logstring2 = cleaningLog(self.oldbuffer.getvalue())

    self.assertEqual("UTCFrameworkNOTICE:message\n", logstring1)
    self.assertEqual(logstring1, logstring2)
    self.buffer.truncate(0)
    self.oldbuffer.truncate(0)

    gLogger.showHeaders(True)
    gLogger.showThreadIDs(True)
    gLogger.notice('message')

    oldgLogger.showHeaders(True)
    oldgLogger.showThreadIDs(True)
    oldgLogger.notice('message')

    logstring1 = cleaningLog(self.buffer.getvalue())
    logstring2 = cleaningLog(self.oldbuffer.getvalue())

    self.assertIn(str(thread.get_ident()), logstring1)
    self.assertNotEqual(logstring1, logstring2)
    self.buffer.truncate(0)
    self.oldbuffer.truncate(0)
Esempio n. 10
0
  def test_02setShowThreadIDsHeaders(self):
    """
    Create a subsubsublogger and create a logrecord
    """
    gLogger.showHeaders(False)
    gLogger.showThreadIDs(False)
    gLogger.notice('message')

    oldgLogger.showHeaders(False)
    oldgLogger.showThreadIDs(False)
    oldgLogger.notice('message')

    self.assertEqual("message\n", self.buffer.getvalue())
    self.assertEqual(self.buffer.getvalue(), self.oldbuffer.getvalue())
    self.buffer.truncate(0)
    self.oldbuffer.truncate(0)

    gLogger.showHeaders(False)
    gLogger.showThreadIDs(True)
    gLogger.notice('message')

    oldgLogger.showHeaders(False)
    oldgLogger.showThreadIDs(True)
    oldgLogger.notice('message')

    self.assertEqual("message\n", self.buffer.getvalue())
    self.assertEqual(self.buffer.getvalue(), self.oldbuffer.getvalue())
    self.buffer.truncate(0)
    self.oldbuffer.truncate(0)

    gLogger.showHeaders(True)
    gLogger.showThreadIDs(False)
    gLogger.notice('message')

    oldgLogger.showHeaders(True)
    oldgLogger.showThreadIDs(False)
    oldgLogger.notice('message')

    logstring1 = cleaningLog(self.buffer.getvalue())
    logstring2 = cleaningLog(self.oldbuffer.getvalue())

    self.assertEqual("UTCFrameworkNOTICE:message\n", logstring1)
    self.assertEqual(logstring1, logstring2)
    self.buffer.truncate(0)
    self.oldbuffer.truncate(0)

    gLogger.showHeaders(True)
    gLogger.showThreadIDs(True)
    gLogger.notice('message')

    oldgLogger.showHeaders(True)
    oldgLogger.showThreadIDs(True)
    oldgLogger.notice('message')

    logstring1 = cleaningLog(self.buffer.getvalue())
    logstring2 = cleaningLog(self.oldbuffer.getvalue())

    self.assertIn(str(thread.get_ident()), logstring1)
    self.assertNotEqual(logstring1, logstring2)
    self.buffer.truncate(0)
    self.oldbuffer.truncate(0)