Package java.util.logging

Examples of java.util.logging.Formatter.format()


        handler.publicSetOutputStream(out);
        handler.publish(r);
        handler.close();
        String msg = new String(out.toByteArray());
        Formatter f = handler.getFormatter();
        assertEquals(msg, f.getHead(handler) + f.format(r) + f.getTail(handler));
        assertFileContent(HOMEPATH, "setoutput.log", handler.getFormatter());
    }

    /*
     * Class under test for void FileHandler(String)
View Full Code Here


    // Output the formatted data to the file
                
                 Formatter f = getFormatter();

                 messages.add(f.format(record));

                 if (messages.size() > 20)
                 {
                     messages.remove(0);
                 }
View Full Code Here

      session = Session.getInstance(mailProps, null);
      msg = new MimeMessage(session);
      msg.setFrom(contextParams.getFrom());
      msg.setRecipients(MimeMessage.RecipientType.TO, contextParams
          .getTo());
      msg.setText(formatter.format(record));
      Transport.send(msg);
    } catch (Exception e) {
      reportError("MonadHandler error: " + e.toString(), e,
          ErrorManager.GENERIC_FAILURE);
    }
View Full Code Here

            System.setProperty(LINE_SEPARATOR_KEY, lineSeparatorValue);
            final LogRecord logRecordInput = new LogRecord(level, logMessage);
            logRecordInput.setThrown(null);

            final Formatter formatter = new SimpleTomEEFormatter();
            final String actualFormatOutput = formatter.format(logRecordInput);

            final String expectedFormatOutput = level.getLocalizedName() + " - " + logMessage + "\n";

            assertEquals(expectedFormatOutput, actualFormatOutput);
        } finally {
View Full Code Here

            System.setProperty(LINE_SEPARATOR_KEY, lineSeparatorValue);
            final LogRecord logRecordInput = new LogRecord(level, logMessage);
            logRecordInput.setThrown(thrown);

            final Formatter formatter = new SimpleTomEEFormatter();
            final String actualFormatOutput = formatter.format(logRecordInput);

            final String expectedFormatOutput = level.getLocalizedName() + " - " + logMessage + lineSeparatorValue + ExceptionUtils.getStackTrace(thrown);

            assertEquals(expectedFormatOutput, actualFormatOutput);
        } finally {
View Full Code Here

                if (e.getClassName().equals(LoggingServiceHandler.class.getName())) {
                    return; // Return doing nothing -- don't recurse sending a message that our own message sending failed!
                }
            }
            Formatter formatter = getFormatter();
            String message = formatter.format(record);
            LogEntry le = new LogEntry();
            le.setDateTime(new Date());
            le.setSeverity(record.getLevel().getName());
            le.setClassName(record.getSourceClassName());
            le.setMessage(message);
View Full Code Here

    JpaLogger jpaLogger = new TestJpaLogger(logger, formatter);

    // set expectations

    expect(severeEntry.getLevel()).andReturn(SessionLog.SEVERE);
    expect(formatter.format((LogRecord) anyObject())).andReturn("severe log message");
    logger.error("severe log message");

    expect(configEntry.getLevel()).andReturn(SessionLog.CONFIG);
    expect(formatter.format((LogRecord) anyObject())).andReturn("config log message");
    logger.info("config log message");
View Full Code Here

    expect(severeEntry.getLevel()).andReturn(SessionLog.SEVERE);
    expect(formatter.format((LogRecord) anyObject())).andReturn("severe log message");
    logger.error("severe log message");

    expect(configEntry.getLevel()).andReturn(SessionLog.CONFIG);
    expect(formatter.format((LogRecord) anyObject())).andReturn("config log message");
    logger.info("config log message");

    expect(finestEntry.getLevel()).andReturn(SessionLog.FINEST);
    expect(formatter.format((LogRecord) anyObject())).andReturn("finest log message");
    logger.debug("finest log message");
View Full Code Here

    expect(configEntry.getLevel()).andReturn(SessionLog.CONFIG);
    expect(formatter.format((LogRecord) anyObject())).andReturn("config log message");
    logger.info("config log message");

    expect(finestEntry.getLevel()).andReturn(SessionLog.FINEST);
    expect(formatter.format((LogRecord) anyObject())).andReturn("finest log message");
    logger.debug("finest log message");

    // replay
    replay(logger, severeEntry, configEntry, finestEntry, formatter);
View Full Code Here

        handler.publicSetOutputStream(out);
        handler.publish(r);
        handler.close();
        String msg = new String(out.toByteArray());
        Formatter f = handler.getFormatter();
        assertEquals(msg, f.getHead(handler) + f.format(r) + f.getTail(handler));
        assertFileContent(HOMEPATH, "setoutput.log", handler.getFormatter(), null);
    }

    /*
     * Class under test for void FileHandler(String)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.