Java Code Examples for java.util.logging.LogRecord

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project cdk, under directory /commons/src/main/java/org/richfaces/cdk/.

Source file: JavaLogger.java

  23 
vote

private LogRecord createRecord(Level level,CharSequence message,Throwable thrown){
  LogRecord record=new LogRecord(level,message != null ? message.toString() : null);
  record.setLoggerName(jdkLogger.getName());
  record.setThrown(thrown);
  fillCallerData(CLASS_NAME,record);
  return record;
}
 

Example 2

From project commons-logging, under directory /src/java/org/apache/commons/logging/impl/.

Source file: Jdk13LumberjackLogger.java

  22 
vote

private void log(Level level,String msg,Throwable ex){
  if (getLogger().isLoggable(level)) {
    LogRecord record=new LogRecord(level,msg);
    if (!classAndMethodFound) {
      getClassAndMethod();
    }
    record.setSourceClassName(sourceClassName);
    record.setSourceMethodName(sourceMethodName);
    if (ex != null) {
      record.setThrown(ex);
    }
    getLogger().log(record);
  }
}
 

Example 3

From project core_4, under directory /api/src/main/java/org/richfaces/log/.

Source file: JavaLogger.java

  22 
vote

private LogRecord createRecord(java.util.logging.Level level,CharSequence message,Throwable thrown){
  LogRecord record=new LogRecord(level,message != null ? message.toString() : null);
  record.setLoggerName(jdkLogger.getName());
  record.setThrown(thrown);
  fillCallerData(CLASS_NAME,record);
  return record;
}
 

Example 4

From project cotopaxi-core, under directory /src/main/java/br/octahedron/util/.

Source file: Log.java

  22 
vote

protected void log(Level level,Throwable t,String message){
  LogRecord record=new LogRecord(level,message);
  record.setSourceClassName(this.name);
  if (t != null) {
    record.setThrown(t);
  }
  this.logger.log(record);
}
 

Example 5

From project cp-common-utils, under directory /src/com/clarkparsia/common/logging/.

Source file: CustomizableJULFormatter.java

  22 
vote

public static void main(String[] args){
  for (  Style style : Style.values()) {
    LogRecord record=new LogRecord(Level.FINE,"This message is formatted with style " + style);
    record.setSourceClassName("com.example.FormatExample");
    record.setSourceMethodName("print");
    CustomizableJULFormatter formatter=new CustomizableJULFormatter(style);
    System.out.print(formatter.format(record));
  }
}
 

Example 6

From project flyingsaucer, under directory /flying-saucer-core/src/main/java/org/xhtmlrenderer/util/.

Source file: Configuration.java

  22 
vote

/** 
 * Sets the logger which we use for Configuration-related logging. Before this is called the first time, all internal log records are queued up; they are flushed to the logger when this method is first called. Afterwards, all log events are written to this logger. This queueing behavior helps avoid order-of-operations bugs related to loading configuration information related to logging.
 * @param logger Logger used for Configuration-related messages
 */
public static void setConfigLogger(Logger logger){
  Configuration config=instance();
  config.configLogger=logger;
  if (config.startupLogRecords != null) {
    Iterator iter=config.startupLogRecords.iterator();
    while (iter.hasNext()) {
      LogRecord lr=(LogRecord)iter.next();
      logger.log(lr.getLevel(),lr.getMessage());
    }
    config.startupLogRecords=null;
  }
}
 

Example 7

From project FML, under directory /common/cpw/mods/fml/relauncher/.

Source file: FMLRelaunchLog.java

  22 
vote

@Override public void run(){
  do {
    LogRecord lr;
    try {
      lr=recordQueue.take();
      wrappedHandler.publish(lr);
    }
 catch (    InterruptedException e) {
      Thread.interrupted();
    }
  }
 while (true);
}
 

Example 8

From project gwt-support, under directory /hudson-gwt-slf4j/src/main/java/org/slf4j/impl/.

Source file: JDK14LoggerAdapter.java

  22 
vote

/** 
 * Log the message at the specified level with the specified throwable if any. This method creates a LogRecord and fills in caller date before calling this instance's JDK14 logger. See bug report #13 for more details.
 * @param level
 * @param msg
 * @param t
 */
private void log(String callerFQCN,Level level,String msg,Throwable t){
  LogRecord record=new LogRecord(level,msg);
  record.setLoggerName(getName());
  record.setThrown(t);
  fillCallerData(callerFQCN,record);
  logger.log(record);
}
 

Example 9

From project jboss-logging, under directory /src/main/java/org/jboss/logging/.

Source file: JBossLogRecord.java

  22 
vote

protected Object writeReplace(){
  final LogRecord replacement=new LogRecord(getLevel(),getMessage());
  replacement.setResourceBundle(getResourceBundle());
  replacement.setLoggerName(getLoggerName());
  replacement.setMillis(getMillis());
  replacement.setParameters(getParameters());
  replacement.setResourceBundleName(getResourceBundleName());
  replacement.setSequenceNumber(getSequenceNumber());
  replacement.setSourceClassName(getSourceClassName());
  replacement.setSourceMethodName(getSourceMethodName());
  replacement.setThreadID(getThreadID());
  replacement.setThrown(getThrown());
  return replacement;
}
 

Example 10

From project jboss-modules, under directory /src/main/java/org/jboss/modules/log/.

Source file: ModuleLogRecord.java

  22 
vote

protected Object writeReplace(){
  final LogRecord replacement=new LogRecord(getLevel(),getMessage());
  replacement.setResourceBundle(getResourceBundle());
  replacement.setLoggerName(getLoggerName());
  replacement.setMillis(getMillis());
  replacement.setParameters(getParameters());
  replacement.setResourceBundleName(getResourceBundleName());
  replacement.setSequenceNumber(getSequenceNumber());
  replacement.setSourceClassName(getSourceClassName());
  replacement.setSourceMethodName(getSourceMethodName());
  replacement.setThreadID(getThreadID());
  replacement.setThrown(getThrown());
  return replacement;
}
 

Example 11

From project jboss-rmi-api_spec, under directory /src/main/java/org/jboss/com/sun/corba/se/spi/logging/.

Source file: LogWrapperBase.java

  22 
vote

protected void doLog(Level level,String key,Object[] params,Class<?> wrapperClass,Throwable thr){
  LogRecord lrec=new LogRecord(level,key);
  if (params != null)   lrec.setParameters(params);
  inferCaller(wrapperClass,lrec);
  lrec.setThrown(thr);
  lrec.setLoggerName(loggerName);
  lrec.setResourceBundle(logger.getResourceBundle());
  logger.log(lrec);
}
 

Example 12

From project slf4j_1, under directory /slf4j-jdk14/src/main/java/org/slf4j/impl/.

Source file: JDK14LoggerAdapter.java

  22 
vote

/** 
 * Log the message at the specified level with the specified throwable if any. This method creates a LogRecord and fills in caller date before calling this instance's JDK14 logger. See bug report #13 for more details.
 * @param level
 * @param msg
 * @param t
 */
private void log(String callerFQCN,Level level,String msg,Throwable t){
  LogRecord record=new LogRecord(level,msg);
  record.setLoggerName(getName());
  record.setThrown(t);
  fillCallerData(callerFQCN,record);
  logger.log(record);
}
 

Example 13

From project zirco-browser, under directory /src/org/emergent/android/weave/client/.

Source file: Dbg.java

  22 
vote

private static void log(Level level,Throwable e){
  if (!sm_logger.isLoggable(level))   return;
  LogRecord lr=new DebugLogRecord(level,"Something was thrown!");
  lr.setThrown(e);
  lr.setLoggerName(sm_logger.getName());
  sm_logger.log(lr);
}
 

Example 14

From project and-bible, under directory /jsword-tweaks/src/main/java/jsword/org/crosswire/common/util/.

Source file: Logger.java

  21 
vote

private void doLogging(Level theLevel,String message,Throwable th){
  initialize();
  LogRecord logRecord=new LogRecord(theLevel,message);
  logRecord.setLoggerName(logger.getName());
  logRecord.setSourceClassName(CallContext.getCallingClass(1).getName());
  logRecord.setThrown(th);
  if (showLocation) {
    String methodName=null;
    int lineNumber=-1;
    StackTraceElement[] stack=(new Throwable()).getStackTrace();
    int ix=0;
    while (ix < stack.length) {
      StackTraceElement frame=stack[ix];
      String cname=frame.getClassName();
      if (cname.equals(CLASS_NAME)) {
        break;
      }
      ix++;
    }
    while (ix < stack.length) {
      StackTraceElement frame=stack[ix];
      if (!frame.getClassName().equals(CLASS_NAME)) {
        methodName=frame.getMethodName();
        lineNumber=frame.getLineNumber();
        break;
      }
      ix++;
    }
    logRecord.setSourceMethodName(methodName);
    logRecord.setSequenceNumber(lineNumber);
  }
  System.out.println("JSword:" + message);
  logger.log(logRecord);
}
 

Example 15

From project guice-jit-providers, under directory /core/test/com/google/inject/.

Source file: BinderTest.java

  21 
vote

public void testUserReportedErrorsAreAlsoLogged(){
  try {
    Guice.createInjector(new AbstractModule(){
      @Override protected void configure(){
        addError(new Message(ImmutableList.of(),"Whoops!",new IllegalArgumentException()));
      }
    }
);
    fail();
  }
 catch (  CreationException expected) {
  }
  LogRecord logRecord=Iterables.getOnlyElement(this.logRecords);
  assertContains(logRecord.getMessage(),"An exception was caught and reported. Message: java.lang.IllegalArgumentException");
}
 

Example 16

From project jsword, under directory /src/main/java/org/crosswire/common/util/.

Source file: Logger.java

  21 
vote

private void doLogging(Level theLevel,String message,Throwable th){
  initialize();
  LogRecord logRecord=new LogRecord(theLevel,message);
  logRecord.setLoggerName(logger.getName());
  logRecord.setSourceClassName(CallContext.getCallingClass(1).getName());
  logRecord.setThrown(th);
  if (showLocation) {
    String methodName=null;
    int lineNumber=-1;
    StackTraceElement[] stack=(new Throwable()).getStackTrace();
    int ix=0;
    while (ix < stack.length) {
      StackTraceElement frame=stack[ix];
      String cname=frame.getClassName();
      if (cname.equals(CLASS_NAME)) {
        break;
      }
      ix++;
    }
    while (ix < stack.length) {
      StackTraceElement frame=stack[ix];
      if (!frame.getClassName().equals(CLASS_NAME)) {
        methodName=frame.getMethodName();
        lineNumber=frame.getLineNumber();
        break;
      }
      ix++;
    }
    logRecord.setSourceMethodName(methodName);
    logRecord.setSequenceNumber(lineNumber);
  }
  logger.log(logRecord);
}
 

Example 17

From project Pipeline, under directory /src/operator/qc/.

Source file: QCReport.java

  21 
vote

private void writeLogPage(StringWriter writer,File outputDir) throws IOException {
  writer.write("<h2> Complete log </h2>");
  Calendar cal=Calendar.getInstance();
  TableWriter table=new TableWriter(3);
  table.setColumnWidth(1,150);
  QueuedLogHandler logHandler=getPipelineOwner().getLogHandler();
  for (int i=0; i < logHandler.getRecordCount(); i++) {
    LogRecord rec=logHandler.getRecord(i);
    cal.setTimeInMillis(rec.getMillis());
    List<String> recRow=new ArrayList<String>(4);
    if (rec.getLevel() == Level.WARNING || (rec.getLevel() == Level.SEVERE)) {
      recRow.add("<div id=\"error\">" + rec.getLevel() + "</div>");
    }
 else {
      recRow.add(rec.getLevel() + "");
    }
    recRow.add((cal.get(Calendar.MONTH) + 1) + "/" + cal.get(Calendar.DAY_OF_MONTH)+ "/"+ cal.get(Calendar.YEAR)+ "  "+ cal.get(Calendar.HOUR_OF_DAY)+ ":"+ cal.get(Calendar.MINUTE)+ ":"+ cal.get(Calendar.SECOND)+ "."+ ("" + (cal.get(Calendar.MILLISECOND) / 1000.0)).replace("0.",""));
    recRow.add(rec.getMessage());
    table.addRow(recRow);
  }
  writer.write(table.getHTML());
}
 

Example 18

From project rj-core, under directory /de.walware.rj.rpkg/src/de/walware/rj/server/jri/.

Source file: JRIServerUtils.java

  21 
vote

public String readFile(final File file,final Charset charset){
  this.rTempStringBuilder.setLength(0);
  InputStreamReader reader=null;
  try {
    reader=new InputStreamReader(new FileInputStream(file),charset);
    int read;
    while ((read=reader.read(this.rTempCharBuffer,0,TEMP_CHAR_BUFFER_LENGTH)) >= 0) {
      this.rTempStringBuilder.append(this.rTempCharBuffer,0,read);
    }
    return reader.toString();
  }
 catch (  final IOException e) {
    final LogRecord record=new LogRecord(Level.WARNING,"An error occurred when reading source file ''{0}''.");
    record.setParameters(new Object[]{file.getAbsolutePath()});
    record.setThrown(e);
    LOGGER.log(record);
    return null;
  }
 finally {
    if (reader != null) {
      try {
        reader.close();
      }
 catch (      final IOException e) {
      }
    }
  }
}
 

Example 19

From project rj-servi, under directory /de.walware.rj.servi/src/de/walware/rj/servi/internal/.

Source file: NodeController.java

  21 
vote

public void start(){
  LOGGER.log(Level.INFO,"{0} Initializing R node...",this.logPrefix);
  final NodeServer server=new NodeServer(this.name,this);
  if (!initREngine(server)) {
    exit(EXIT_INIT_RENGINE_ERROR);
  }
  try {
    server.start1();
    LOGGER.log(Level.FINE,"{0} Initializing R node: R engine started and initialized.",this.logPrefix);
  }
 catch (  final Exception e) {
    final LogRecord record=new LogRecord(Level.SEVERE,"{0} Initializing R node failed.");
    record.setParameters(new Object[]{this.logPrefix});
    record.setThrown(e);
    LOGGER.log(record);
    exit(EXIT_START_RENGINE_ERROR);
  }
  LOGGER.log(Level.FINE,"{0} Initializing R node: Publishing in registry...",this.logPrefix);
  publishServer(server);
}
 

Example 20

From project sisu-guice, under directory /core/test/com/google/inject/.

Source file: BinderTest.java

  21 
vote

public void testUserReportedErrorsAreAlsoLogged(){
  try {
    Guice.createInjector(new AbstractModule(){
      @Override protected void configure(){
        addError(new Message(ImmutableList.of(),"Whoops!",new IllegalArgumentException()));
      }
    }
);
    fail();
  }
 catch (  CreationException expected) {
  }
  LogRecord logRecord=Iterables.getOnlyElement(this.logRecords);
  assertContains(logRecord.getMessage(),"An exception was caught and reported. Message: java.lang.IllegalArgumentException");
}
 

Example 21

From project spring-shell, under directory /src/main/java/org/springframework/shell/support/logging/.

Source file: LoggingOutputStream.java

  21 
vote

@Override public void flush() throws IOException {
  if (count > 0) {
    String msg=new String(baos.toByteArray());
    LogRecord record=new LogRecord(level,msg);
    record.setSourceClassName(sourceClassName);
    try {
      LOGGER.log(record);
    }
  finally {
      count=0;
      IOUtils.closeQuietly(baos);
      baos=new ByteArrayOutputStream();
    }
  }
}
 

Example 22

From project netnumeri, under directory /lib/gwt-2.5.0.rc1/samples/LogExample/src/com/google/gwt/sample/logexample/client/.

Source file: LogExample.java

  20 
vote

public void onModuleLoad(){
  HTMLPanel p=uiBinder.createAndBindUi(this);
  RootPanel.get().add(p);
  loggerControls.setWidget(new LoggerController(rootLogger,parentLogger,childLogger).getPanel());
  handlerControls.setWidget(new HandlerController(rootLogger).getPanel());
  logOnServerButton.setWidget(new ServerLoggingArea().getPanel());
  customLogArea.setWidget(new CustomLogArea(childLogger).getPanel());
  Handler[] handlers=Logger.getLogger("").getHandlers();
  if (handlers != null) {
    for (    Handler h : handlers) {
      if (h instanceof HasWidgetsLogHandler) {
        String msg="This popup can be resized, moved and minimized";
        h.publish(new LogRecord(Level.SEVERE,msg));
      }
    }
  }
}
 

Example 23

From project AdServing, under directory /modules/utilities/utils/src/main/java/net/mad/ads/base/utils/utils/logging/.

Source file: CustomMessageFormatter.java

  19 
vote

@Override public String format(LogRecord record){
  Object[] arguments=new Object[4];
  arguments[0]=record.getLevel();
  arguments[1]=Thread.currentThread().getName();
  arguments[2]=new Date(record.getMillis());
  arguments[3]=record.getMessage();
  return messageFormat.format(arguments);
}
 

Example 24

From project AeminiumRuntime, under directory /src/aeminium/runtime/tests/.

Source file: BaseTest.java

  19 
vote

public BaseTest(){
  log=Logger.getLogger(this.getClass().getName());
  Handler conHdlr=new ConsoleHandler();
  conHdlr.setFormatter(new Formatter(){
    public String format(    LogRecord record){
      return "TEST " + record.getLevel() + "  :  "+ record.getMessage()+ "\n";
    }
  }
);
  log.setUseParentHandlers(false);
  log.addHandler(conHdlr);
  log.setLevel(Level.INFO);
}
 

Example 25

From project autopsy, under directory /Core/src/org/sleuthkit/autopsy/coreutils/.

Source file: AutopsyExceptionHandler.java

  19 
vote

@Override public void publish(LogRecord record){
  if (isLoggable(record)) {
    if (record.getMessage() != null) {
      final int levelValue=record.getLevel().intValue();
      final Component parentComponent=null;
      final String message=formatExplanation(record);
      final String title=getTitleForLevelValue(levelValue);
      final int messageType=getMessageTypeForLevelValue(levelValue);
      SwingUtilities.invokeLater(new Runnable(){
        @Override public void run(){
          JOptionPane.showMessageDialog(parentComponent,message,title,messageType);
        }
      }
);
    }
 else {
      nbErrorManager.publish(record);
    }
  }
}
 

Example 26

From project beanmill_1, under directory /src/main/java/com/traxel/lumbermill/event/.

Source file: Event.java

  19 
vote

/** 
 * DOCUMENT ME!
 * @param object  DOCUMENT ME!
 * @return  DOCUMENT ME!
 */
protected static Event create(final Object object){
  final Event event;
  if (object == null) {
    event=null;
  }
 else   if (object instanceof LogRecord) {
    event=new JavaEvent((LogRecord)object);
  }
 else   if (object instanceof LoggingEvent) {
    event=new Log4jEvent((LoggingEvent)object);
  }
 else {
    event=null;
  }
  return event;
}
 

Example 27

From project BeeQueue, under directory /src/org/beequeue/util/.

Source file: LoggingUtil.java

  19 
vote

public static void setSimpleFormatter(ConsoleHandler ch){
  ch.setFormatter(new Formatter(){
    @Override public String format(    LogRecord r){
      String date=new SimpleDateFormat("yyyy-MM-dd hh:mm.ss ").format(new Date(r.getMillis()));
      return date + r.getLevel() + " "+ r.getLoggerName()+ "#"+ r.getSourceMethodName()+ " "+ r.getMessage()+ "\n";
    }
  }
);
}
 

Example 28

From project capedwarf-blue, under directory /log/src/main/java/org/jboss/capedwarf/log/.

Source file: JBossLogService.java

  19 
vote

public void log(LogRecord record){
  JBossDelegate jBossDelegate=JBossDelegate.INSTANCE;
  ServletRequest request=jBossDelegate.getServletRequest();
  Entity entity=new Entity(LOG_LINE_ENTITY_KIND);
  entity.setProperty(LOG_LINE_LOGGER,record.getLoggerName());
  entity.setProperty(LOG_LINE_LEVEL,getLogLevel(record).ordinal());
  entity.setProperty(LOG_LINE_MILLIS,record.getMillis());
  entity.setProperty(LOG_LINE_THROWN,record.getThrown());
  entity.setProperty(LOG_LINE_MESSAGE,record.getMessage());
  entity.setProperty(LOG_LINE_REQUEST_KEY,getRequestEntityKey(request));
  DatastoreServiceFactory.getDatastoreService().put(entity);
}
 

Example 29

From project CCR-Validator, under directory /src/main/java/org/openhealthdata/.

Source file: OpenHealthSimpleLogFormatter.java

  19 
vote

@Override public String format(LogRecord record){
  String loggerName=record.getLoggerName();
  if (loggerName == null) {
    loggerName="root";
  }
  StringBuilder output=new StringBuilder().append(loggerName).append("-").append(record.getSourceMethodName()).append("[").append(record.getLevel()).append('|').append(Thread.currentThread().getName()).append('|').append(format.format(new Date(record.getMillis()))).append("]: ").append(record.getMessage()).append(' ').append(lineSep);
  if (record.getThrown() != null) {
    try {
      StringWriter sw=new StringWriter();
      PrintWriter pw=new PrintWriter(sw);
      record.getThrown().printStackTrace(pw);
      pw.close();
      output.append(sw.toString());
    }
 catch (    Exception ex) {
    }
  }
  return output.toString();
}
 

Example 30

From project Clotho-Core, under directory /ClothoApps/SequenceChecker/src/jaligner/ui/logging/.

Source file: DocumentHandler.java

  19 
vote

/** 
 */
public void publish(LogRecord record){
  if (!isLoggable(record)) {
    return;
  }
  String message;
  try {
    message=getFormatter().format(record);
  }
 catch (  Exception exception) {
    reportError(null,exception,ErrorManager.FORMAT_FAILURE);
    return;
  }
synchronized (textPane) {
    if (textPane.getDocument().getLength() >= MAXIMUM_DOCUMENT_SIZE) {
      textPane.setText("");
    }
    try {
      if (record.getLevel() == Level.SEVERE) {
        textPane.getDocument().insertString(textPane.getDocument().getLength(),message,severStyle);
      }
 else {
        textPane.getDocument().insertString(textPane.getDocument().getLength(),message,infoStyle);
      }
      textPane.setCaretPosition(textPane.getDocument().getLength());
    }
 catch (    Exception ex) {
      reportError(null,ex,ErrorManager.WRITE_FAILURE);
    }
  }
}
 

Example 31

From project cloudify, under directory /CLI/src/main/java/org/cloudifysource/shell/installer/.

Source file: ConnectionLogsFilter.java

  19 
vote

private void supressConnectionErrors(final Logger logger,final Filter filter){
  Filter newFilter=new Filter(){
    /** 
 * {@inheritDoc}
 */
    @Override public boolean isLoggable(    final LogRecord record){
      boolean isLoggable=true;
      Throwable t=record.getThrown();
      if ((filter != null && !filter.isLoggable(record)) || (t != null && isConnectExceptionOrCause(t) && record.getLevel().intValue() <= Level.WARNING.intValue())) {
        isLoggable=false;
      }
      return isLoggable;
    }
    private boolean isConnectExceptionOrCause(    Throwable throwable){
      while (throwable != null) {
        if (isConnectException(throwable)) {
          return true;
        }
        throwable=throwable.getCause();
      }
      return false;
    }
    private boolean isConnectException(    final Throwable t){
      return (t instanceof java.net.SocketException) || (t instanceof java.rmi.ConnectException);
    }
  }
;
  logger.setFilter(newFilter);
}
 

Example 32

From project CommitCoin, under directory /src/com/google/bitcoin/utils/.

Source file: BriefLogFormatter.java

  19 
vote

@Override public String format(LogRecord logRecord){
  Object[] arguments=new Object[6];
  arguments[0]=logRecord.getThreadID();
  String fullClassName=logRecord.getSourceClassName();
  int lastDot=fullClassName.lastIndexOf('.');
  String className=fullClassName.substring(lastDot + 1);
  arguments[1]=className;
  arguments[2]=logRecord.getSourceMethodName();
  arguments[3]=new Date(logRecord.getMillis());
  arguments[4]=logRecord.getMessage();
  if (logRecord.getThrown() != null) {
    Writer result=new StringWriter();
    logRecord.getThrown().printStackTrace(new PrintWriter(result));
    arguments[5]=result.toString();
  }
 else {
    arguments[5]="";
  }
  return messageFormat.format(arguments);
}
 

Example 33

From project Custom-Salem, under directory /src/haven/error/.

Source file: ErrorLogFormatter.java

  19 
vote

@Override public synchronized String format(LogRecord record){
  long now=record.getMillis();
  dat.setTime(now);
  String message=formatMessage(record) + "\n";
  if (now - last > 1000) {
    message=String.format("%s\n%s",dat.toString(),message);
  }
  last=now;
  return message;
}
 

Example 34

From project Cyborg, under directory /src/main/java/com/alta189/cyborg/.

Source file: CommonFormatter.java

  19 
vote

@Override public String format(LogRecord record){
  StringBuilder builder=new StringBuilder();
  builder.append("[").append(record.getLevel().getLocalizedName()).append("] ").append(formatMessage(record)).append(lineSep);
  Throwable throwable=record.getThrown();
  if (throwable != null) {
    StringWriter sw=new StringWriter();
    throwable.printStackTrace(new PrintWriter(sw,true));
    builder.append(sw.toString());
  }
  return builder.toString();
}
 

Example 35

From project eik, under directory /plugins/info.evanchik.karaf.app/src/main/java/org/apache/felix/karaf/main/.

Source file: BootstrapLogManager.java

  19 
vote

@Override public synchronized void publish(LogRecord record){
  if (!isLoggable(record)) {
    return;
  }
  super.publish(record);
  flush();
}
 

Example 36

From project elw, under directory /datapath-gui/src/main/java/elw/dp/ui/.

Source file: FeedbackHandler.java

  19 
vote

@Override public void publish(final LogRecord record){
  final Style style=styles.get(record.getLevel());
  final String message=dateFormat.format(new Date(record.getMillis())) + " " + record.getSourceClassName()+ "."+ record.getSourceMethodName()+ "() "+ record.getMessage();
  SwingUtilities.invokeLater(new Runnable(){
    public void run(){
      final Document document=outputPane.getDocument();
      try {
        final int lastTraceStart=traceStart;
        if (lastTraceStart > 0) {
          document.remove(lastTraceStart,document.getLength() - lastTraceStart);
          traceStart=-1;
        }
      }
 catch (      BadLocationException e) {
      }
      try {
        final int prevLength=document.getLength();
        document.insertString(prevLength,message + "\n",style.copyAttributes());
        if (Level.INFO.intValue() > record.getLevel().intValue()) {
          traceStart=prevLength;
        }
      }
 catch (      BadLocationException e) {
      }
    }
  }
);
}
 

Example 37

From project en, under directory /src/l1j/server/.

Source file: ConsoleLogFormatter.java

  19 
vote

@Override public String format(LogRecord record){
  StringBuffer output=new StringBuffer();
  output.append(dateFmt.format(new Date(record.getMillis())));
  output.append(" ");
  output.append(record.getMessage());
  output.append("\r\n");
  if (record.getThrown() != null) {
    try {
      StringWriter sw=new StringWriter();
      PrintWriter pw=new PrintWriter(sw);
      record.getThrown().printStackTrace(pw);
      pw.close();
      output.append(dateFmt.format(new Date(record.getMillis())));
      output.append(" ");
      output.append(sw.toString());
      output.append("\r\n");
    }
 catch (    Exception ex) {
    }
  }
  return output.toString();
}
 

Example 38

From project encog-java-core, under directory /src/main/java/org/encog/util/logging/.

Source file: EncogFormatter.java

  19 
vote

/** 
 * Format the log record.
 * @param record What to log.
 * @return The formatted log record.
 */
@Override public String format(final LogRecord record){
  final StringBuilder result=new StringBuilder();
  result.append("[");
  result.append(record.getLevel());
  result.append("] [");
  result.append(record.getSourceClassName());
  result.append("] ");
  result.append(record.getMessage());
  result.append("\n");
  return result.toString();
}
 

Example 39

From project freemind, under directory /freemind/freemind/main/.

Source file: StdFormatter.java

  19 
vote

/** 
 * Format the given LogRecord.
 * @param record the log record to be formatted.
 * @return a formatted log record
 */
public synchronized String format(LogRecord record){
  if (!STDERR.getName().equals(record.getLoggerName()) && !STDOUT.getName().equals(record.getLoggerName())) {
    return super.format(record);
  }
  StringBuffer sb=new StringBuffer();
  sb.append(lineSeparator);
  String message=formatMessage(record);
  sb.append(record.getLevel().getLocalizedName());
  sb.append(": ");
  sb.append(message);
  return sb.toString();
}
 

Example 40

From project galaxy, under directory /src/co/paralleluniverse/common/logging/.

Source file: SimpleFormatter.java

  19 
vote

@Override public synchronized String format(LogRecord record){
  dat.setTime(record.getMillis());
  String source;
  if (record.getSourceClassName() != null) {
    source=record.getSourceClassName();
    if (record.getSourceMethodName() != null) {
      source+=" " + record.getSourceMethodName();
    }
  }
 else {
    source=record.getLoggerName();
  }
  String message=formatMessage(record);
  String throwable="";
  if (record.getThrown() != null) {
    StringWriter sw=new StringWriter();
    PrintWriter pw=new PrintWriter(sw);
    pw.println();
    record.getThrown().printStackTrace(pw);
    pw.close();
    throwable=sw.toString();
  }
  return String.format(format,dat,source,record.getLoggerName(),record.getLevel().getLocalizedName(),message,throwable,record.getThreadID());
}
 

Example 41

From project gwtphonegap, under directory /src/main/java/com/googlecode/gwtphonegap/client/log/.

Source file: PhoneGapConsoleLogHandler.java

  19 
vote

@Override public void publish(LogRecord record){
  if (!supportsLogging)   return;
  if (!isLoggable(record)) {
    return;
  }
  String msg=getFormatter().format(record);
  log(msg);
}
 

Example 42

From project heritrix3, under directory /commons/src/main/java/org/archive/io/.

Source file: GenerationFileHandler.java

  19 
vote

@Override public void publish(LogRecord record){
  Formatter f=getFormatter();
  if (!(f instanceof Preformatter)) {
    super.publish(record);
  }
 else {
    try {
      ((Preformatter)f).preformat(record);
      super.publish(record);
    }
  finally {
      ((Preformatter)f).clear();
    }
  }
}
 

Example 43

From project huiswerk, under directory /print/zxing-1.6/zxingorg/src/com/google/zxing/web/.

Source file: ServletContextLogHandler.java

  19 
vote

@Override public void publish(LogRecord record){
  Formatter formatter=getFormatter();
  String message;
  if (formatter == null) {
    message=record.getMessage();
  }
 else {
    message=formatter.format(record);
  }
  Throwable throwable=record.getThrown();
  if (throwable == null) {
    context.log(message);
  }
 else {
    context.log(message,throwable);
  }
}
 

Example 44

From project Java-Chronicle, under directory /testing/src/main/java/vanilla/java/chronicle/impl/.

Source file: FileLoggingMain.java

  19 
vote

private static long timeLogToLogger(int count) throws IOException {
  long start=System.nanoTime();
  FileHandler handler=new FileHandler("my.logger.log");
  handler.setFormatter(new Formatter(){
    @Override public String format(    LogRecord record){
      return TIME.format(record.getMillis()) + " [ " + Thread.currentThread().getName()+ " ] "+ record.getLevel()+ " "+ record.getMessage()+ "\n";
    }
  }
);
  Logger logger=Logger.getLogger("vanilla.java.chronicle");
  logger.addHandler(handler);
  logger.setLevel(Level.FINE);
  double d=0.001, factor=1 + 10.0 / count;
  for (int i=0; i < count; i++) {
    d*=factor;
    logger.log(Level.FINE,"result= " + d);
  }
  handler.close();
  return System.nanoTime() - start;
}
 

Example 45

From project java-psd-library, under directory /psd-analizer/src/analizer/.

Source file: PsdAnalizer.java

  19 
vote

private static void configureLogs(){
  Logger psdLogger=Logger.getLogger("");
  psdLogger.setLevel(Level.ALL);
  Handler[] handlers=psdLogger.getHandlers();
  for (  Handler handler : handlers) {
    psdLogger.removeHandler(handler);
  }
  psdLogger.addHandler(new ConsoleHandler(){
    public void publish(    LogRecord rec){
      System.out.println(rec.getLevel() + ": " + rec.getMessage());
    }
  }
);
}
 

Example 46

From project jboss-logmanager, under directory /src/main/java/org/jboss/logmanager/.

Source file: ExtLogRecord.java

  19 
vote

/** 
 * Wrap a JDK log record.  If the target record is already an  {@code ExtLogRecord}, it is simply returned.  Otherwise a wrapper record is created and returned.
 * @param rec the original record
 * @return the wrapped record
 */
public static ExtLogRecord wrap(LogRecord rec){
  if (rec == null) {
    return null;
  }
 else   if (rec instanceof ExtLogRecord) {
    return (ExtLogRecord)rec;
  }
 else {
    return new WrappedExtLogRecord(rec);
  }
}
 

Example 47

From project jCAE, under directory /amibe/src/org/jcae/mesh/.

Source file: JCAEFormatter.java

  19 
vote

@Override public final String format(LogRecord record){
  String loggerName=record.getLoggerName();
  if (loggerName == null) {
    loggerName="root";
  }
  if (startDate < 0L) {
    startDate=record.getMillis();
  }
  StringBuilder output=new StringBuilder().append(record.getMillis() - startDate).append(" [").append(record.getLevel()).append("] ").append(loggerName).append("- ").append(record.getMessage()).append(lineSep);
  return output.toString();
}
 

Example 48

From project jclouds-chef, under directory /demos/gae/src/main/java/org/jclouds/chef/demo/config/.

Source file: MessageFormatFormatter.java

  19 
vote

@Override public String format(LogRecord record){
  Object[] arguments=new Object[6];
  arguments[0]=new Date(record.getMillis());
  arguments[1]=record.getLevel();
  arguments[3]=record.getLoggerName();
  arguments[2]=Thread.currentThread().getName();
  arguments[4]=record.getMessage();
  arguments[5]=record.getThrown() != null ? Throwables.getStackTraceAsString(record.getThrown()) : null;
  return arguments[5] == null ? messageFormat.format(arguments) : thrownFormat.format(arguments);
}
 

Example 49

From project jobcreator-tool, under directory /src/main/java/dk/hlyh/hudson/tools/jobcreator/helper/.

Source file: LogFormatter.java

  19 
vote

@Override public String format(LogRecord record){
  StringBuilder sb=new StringBuilder();
  sb.append(record.getLevel()).append(": ");
  sb.append(formatMessage(record));
  sb.append(lineSep);
  if (record.getThrown() != null) {
    System.out.println("Has exception");
    StringWriter sink=new StringWriter();
    record.getThrown().printStackTrace(new PrintWriter(sink,true));
    sb.append(sink.toString());
  }
  return sb.toString();
}
 

Example 50

From project JoSQL, under directory /src/main/java/org/josql/filters/.

Source file: JoSQLLogRecordFilter.java

  19 
vote

public boolean accept(Object o){
  if (!(o instanceof LogRecord)) {
    throw new IllegalArgumentException("Expected object to be of type: " + LogRecord.class.getName() + ", got: "+ o.getClass().getName());
  }
  return this.accept((LogRecord)o);
}
 

Example 51

From project jredis, under directory /core/ri/src/main/java/org/jredis/ri/alphazero/support/.

Source file: Log.java

  19 
vote

@SuppressWarnings("boxing") @Override final public String format(LogRecord record){
  final Level level=record.getLevel();
  final String logger=record.getLoggerName();
  final String msg=record.getMessage();
  final Object[] msgparams=record.getParameters();
  final int tid=record.getThreadID();
  final long time=record.getMillis();
  String _msg=null;
  if (msgparams != null && msgparams.length > 0) {
    _msg=String.format(msg,msgparams);
  }
 else {
    _msg=msg;
  }
  final Date d=new Date(time);
  return String.format("%014d %s %s[tid:%d] <%s>: %s%s",time,d,logger,tid,level.getLocalizedName(),_msg,LINESEP);
}
 

Example 52

From project js4emf, under directory /org.eclipse.emf.js4emf.ui/src/org/eclipse/emf/js4emf/ui/.

Source file: PlatformLoggerHandler.java

  19 
vote

public void publish(LogRecord record){
  int severity=IStatus.OK;
  if (record.getLevel() == Level.SEVERE) {
    severity=IStatus.ERROR;
  }
 else   if (record.getLevel() == Level.WARNING) {
    severity=IStatus.WARNING;
  }
 else   if (record.getLevel() == Level.INFO) {
    severity=IStatus.INFO;
  }
  Throwable throwable=record.getThrown();
  String message=record.getMessage();
  if (message != null) {
    if (record.getParameters() != null) {
      message=MessageFormat.format(record.getMessage(),record.getParameters());
    }
  }
 else   if (throwable != null) {
    if (throwable.getMessage() != null) {
      message=throwable.getMessage();
    }
  }
  final Status status=new Status(IStatus.ERROR,record.getLoggerName(),severity,message,throwable);
  Display.getDefault().asyncExec(new Runnable(){
    public void run(){
      Platform.getLog(bundle).log(status);
    }
  }
);
}
 

Example 53

From project karaf, under directory /main/src/main/java/org/apache/karaf/main/util/.

Source file: BootstrapLogManager.java

  19 
vote

public synchronized void publish(LogRecord record){
  if (!isLoggable(record)) {
    return;
  }
  super.publish(record);
  flush();
}
 

Example 54

From project lilith, under directory /jul/jul-slf4j-handler/src/main/java/de/huxhorn/lilith/handler/.

Source file: Slf4JHandler.java

  19 
vote

private void logRecord(LogRecord record){
  Level julLevel=record.getLevel();
  int julLevelValue=julLevel.intValue();
  if (julLevelValue <= TRACE_LEVEL_THRESHOLD) {
    logTrace(record);
  }
 else   if (julLevelValue <= DEBUG_LEVEL_THRESHOLD) {
    logDebug(record);
  }
 else   if (julLevelValue <= INFO_LEVEL_THRESHOLD) {
    logInfo(record);
  }
 else   if (julLevelValue <= WARN_LEVEL_THRESHOLD) {
    logWarn(record);
  }
 else {
    logError(record);
  }
}
 

Example 55

From project Lily, under directory /global/test-fw/src/main/java/org/lilyproject/testfw/.

Source file: JavaLoggingToLog4jRedirector.java

  19 
vote

@Override public void publish(LogRecord record){
  org.apache.log4j.Logger logger=getLog(record.getLoggerName());
  String message=record.getMessage();
  Throwable exception=record.getThrown();
  Level level=record.getLevel();
  if (level == Level.SEVERE) {
    logger.error(message,exception);
  }
 else   if (level == Level.WARNING) {
    logger.warn(message,exception);
  }
 else   if (level == Level.INFO) {
    logger.info(message,exception);
  }
 else   if (level == Level.CONFIG) {
    logger.debug(message,exception);
  }
 else {
    logger.trace(message,exception);
  }
}
 

Example 56

From project liquibase, under directory /liquibase-core/src/main/java/liquibase/integration/ant/.

Source file: BaseLiquibaseTask.java

  19 
vote

protected Handler createHandler(){
  return new Handler(){
    @Override public void publish(    LogRecord logRecord){
      task.log(logRecord.getMessage(),mapLevelToAntLevel(logRecord.getLevel()));
    }
    @Override public void close() throws SecurityException {
    }
    @Override public void flush(){
    }
    protected int mapLevelToAntLevel(    Level level){
      if (Level.ALL == level) {
        return Project.MSG_INFO;
      }
 else       if (Level.SEVERE == level) {
        return Project.MSG_ERR;
      }
 else       if (Level.WARNING == level) {
        return Project.MSG_WARN;
      }
 else       if (Level.INFO == level) {
        return Project.MSG_INFO;
      }
 else {
        return Project.MSG_VERBOSE;
      }
    }
  }
;
}
 

Example 57

From project liquidfeedback-java-sdk, under directory /core/src/test/java/lfapi/v2/services/.

Source file: BaseTestService.java

  19 
vote

/** 
 * Returns a formatted string of the given log record.
 * @param record the log record to format.
 * @return a formatted string of the given log record.
 */
@Override public String format(LogRecord record){
  StringBuffer sb=new StringBuffer();
  sb.append(record.getSourceClassName().replaceFirst(".*\\.(.*)$","$1"));
  sb.append(".");
  sb.append(record.getSourceMethodName());
  sb.append(": ");
  sb.append(record.getMessage());
  sb.append("\n");
  return sb.toString();
}
 

Example 58

From project livetribe-slp, under directory /core/src/main/java/org/livetribe/slp/util/logging/.

Source file: SimpleFormatter.java

  19 
vote

public String format(LogRecord record){
  StringBuffer result=new StringBuffer();
  result.append(record.getMillis()).append(" ");
  result.append("{").append(record.getThreadID()).append("} ");
  result.append("[").append(getSimpleLoggerName(record.getLoggerName())).append("] ");
  result.append(record.getLevel().getLocalizedName()).append(": ");
  result.append(formatMessage(record)).append(EOL);
  Throwable x=record.getThrown();
  if (x != null) {
    StringWriter sw=new StringWriter();
    PrintWriter pw=new PrintWriter(sw);
    x.printStackTrace(pw);
    pw.close();
    result.append(sw.toString());
  }
  return result.toString();
}
 

Example 59

From project log4j-jboss-logmanager, under directory /src/main/java/org/apache/log4j/.

Source file: JBossFilterWrapper.java

  19 
vote

public boolean isLoggable(final LogRecord record){
  final ExtLogRecord extRec=ExtLogRecord.wrap(record);
  Filter filter=filterChain;
  while (filter != null) {
    final int result=filter.decide(new LoggingEvent(extRec,Logger.getLogger(record.getLoggerName())));
switch (result) {
case Filter.DENY:
      return false;
case Filter.ACCEPT:
    return true;
}
filter=filter.getNext();
}
return defaultResult;
}
 

Example 60

From project medsavant, under directory /MedSavantServerEngine/src/org/ut/biolab/medsavant/db/util/.

Source file: DBLoggingHandler.java

  19 
vote

@Override public void publish(LogRecord lr){
  try {
    TableSchema table=MedSavantDatabase.ServerlogTableSchema;
    InsertQuery query=new InsertQuery(table.getTable());
    query.addColumn(table.getDBColumn(ServerLogTableSchema.COLUMNNAME_OF_USER),userName);
    query.addColumn(table.getDBColumn(ServerLogTableSchema.COLUMNNAME_OF_EVENT),lr.getLevel());
    query.addColumn(table.getDBColumn(ServerLogTableSchema.COLUMNNAME_OF_DESCRIPTION),lr.getMessage());
    query.addColumn(table.getDBColumn(ServerLogTableSchema.COLUMNNAME_OF_TIMESTAMP),new Timestamp(new Date().getTime()));
    ConnectionController.executePreparedUpdate(sessionID,query.toString());
  }
 catch (  SQLException x) {
    LOG.log(Level.SEVERE,null,x);
  }
}
 

Example 61

From project mkgmap, under directory /src/uk/me/parabola/log/.

Source file: UsefulFormatter.java

  19 
vote

public String format(LogRecord record){
  StringBuffer sb=new StringBuffer();
  if (showTime) {
    long millis=record.getMillis();
    Calendar cal=Calendar.getInstance();
    cal.setTimeInMillis(millis);
    sb.append(cal.get(Calendar.YEAR));
    sb.append('/');
    sb.append(fmt2(cal.get(Calendar.MONTH) + 1));
    sb.append('/');
    sb.append(fmt2(cal.get(Calendar.DAY_OF_MONTH)));
    sb.append(' ');
    sb.append(fmt2(cal.get(Calendar.HOUR_OF_DAY)));
    sb.append(':');
    sb.append(fmt2(cal.get(Calendar.MINUTE)));
    sb.append(':');
    sb.append(fmt2(cal.get(Calendar.SECOND)));
    sb.append(' ');
  }
  sb.append(record.getLevel().getLocalizedName());
  sb.append(" (");
  sb.append(shortName(record.getLoggerName()));
  sb.append("): ");
  sb.append(record.getMessage());
  sb.append('\n');
  @SuppressWarnings({"ThrowableResultOfMethodCallIgnored"}) Throwable t=record.getThrown();
  if (t != null) {
    StringWriter out=new StringWriter();
    PrintWriter pw=new PrintWriter(out);
    t.printStackTrace(pw);
    sb.append(out.toString());
  }
  return sb.toString();
}
 

Example 62

From project Mobile-Tour-Guide, under directory /zxing-2.0/zxingorg/src/com/google/zxing/web/.

Source file: ServletContextLogHandler.java

  19 
vote

@Override public void publish(LogRecord record){
  Formatter formatter=getFormatter();
  String message;
  if (formatter == null) {
    message=record.getMessage();
  }
 else {
    message=formatter.format(record);
  }
  Throwable throwable=record.getThrown();
  if (throwable == null) {
    context.log(message);
  }
 else {
    context.log(message,throwable);
  }
}
 

Example 63

From project morphia, under directory /morphia/src/main/java/com/google/code/morphia/logging/jdk/.

Source file: ShortFormatter.java

  19 
vote

@Override public String format(LogRecord record){
  StringBuffer sb=new StringBuffer();
  String source=record.getSourceClassName() == null ? record.getLoggerName() : record.getSourceClassName();
  source=source.substring(source.length() - 15) + "." + (record.getSourceMethodName() == null ? "" : record.getSourceMethodName());
  Object[] arguments=new Object[6];
  arguments[0]=source;
  arguments[1]=record.getLevel();
  arguments[2]=Thread.currentThread().getName();
  arguments[3]=new Date(record.getMillis());
  arguments[4]=record.getMessage();
  sb.append(messageFormat.format(arguments));
  if (record.getThrown() != null) {
    try {
      StringWriter sw=new StringWriter();
      PrintWriter pw=new PrintWriter(sw);
      record.getThrown().printStackTrace(pw);
      pw.close();
      sb.append(sw.toString());
    }
 catch (    Exception ex) {
    }
  }
  sb.append("\n");
  return sb.toString();
}
 

Example 64

From project MyWolf, under directory /src/de/Keyle/MyWolf/util/logger/.

Source file: LogFormat.java

  19 
vote

@Override public String format(LogRecord record){
  String text=new SimpleDateFormat("MM-dd-yyyy HH:mm").format(new Date(record.getMillis()));
  Level level=record.getLevel();
  if (level == Level.FINEST) {
    text+=" [FINEST]";
  }
 else   if (level == Level.FINER) {
    text+=" [FINER]";
  }
 else   if (level == Level.FINE) {
    text+=" [FINE]";
  }
 else   if (level == Level.WARNING) {
    text+=" [WARNING]";
  }
 else   if (level == Level.SEVERE) {
    text+=" [SEVERE]";
  }
 else {
    text+=" [INFO]";
  }
  text+=" " + record.getMessage();
  text+="\r\n";
  Throwable thrown=record.getThrown();
  if (thrown != null) {
    StringWriter stringWriter=new StringWriter();
    thrown.printStackTrace(new PrintWriter(stringWriter));
    text+=stringWriter;
  }
  return text;
}
 

Example 65

From project nuxeo-common, under directory /src/main/java/org/nuxeo/common/logging/.

Source file: JavaUtilLoggingHelper.java

  19 
vote

protected void doPublish(LogRecord record){
  Level level=record.getLevel();
  if (level == Level.FINER || level == Level.FINEST) {
    return;
  }
  String name=record.getLoggerName();
  Log log=cache.get(name);
  if (log == null) {
    log=LogFactory.getLog(name);
    cache.put(name,log);
  }
  if (level == Level.FINE) {
    log.trace(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.CONFIG) {
    log.debug(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.INFO) {
    log.info(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.WARNING) {
    log.warn(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.SEVERE) {
    log.error(record.getMessage(),record.getThrown());
  }
}
 

Example 66

From project nuxeo-tycho-osgi, under directory /nuxeo-common/src/main/java/org/nuxeo/common/logging/.

Source file: JavaUtilLoggingHelper.java

  19 
vote

protected void doPublish(LogRecord record){
  Level level=record.getLevel();
  if (level == Level.FINER || level == Level.FINEST) {
    return;
  }
  String name=record.getLoggerName();
  Log log=cache.get(name);
  if (log == null) {
    log=LogFactory.getLog(name);
    cache.put(name,log);
  }
  if (level == Level.FINE) {
    log.trace(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.CONFIG) {
    log.debug(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.INFO) {
    log.info(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.WARNING) {
    log.warn(record.getMessage(),record.getThrown());
  }
 else   if (level == Level.SEVERE) {
    log.error(record.getMessage(),record.getThrown());
  }
}
 

Example 67

From project Opal, under directory /discontinued/opal-shade/src/main/java/com/lyndir/lhunath/opal/gui/template/shade/.

Source file: AbstractUi.java

  19 
vote

/** 
 * {@inheritDoc}
 */
@Override public void logMessage(final LogRecord record){
  if ((log == null || log.getParent() == null) && record.getLevel().intValue() > Level.CONFIG.intValue() && console == null)   toggleConsole();
  if (log != null)   SwingUtilities.invokeLater(new Runnable(){
    @Override public void run(){
      String message=record.getMessage();
      Level level=record.getLevel();
      if (message != null || record.getThrown() != null)       try {
        log.getEditorKit().read(new StringReader(logFormatter.format(record)),log.getDocument(),log.getDocument().getLength());
      }
 catch (      IOException e) {
        logger.err(e,"Couldn't read the log message from the record!");
      }
catch (      BadLocationException e) {
        logger.err(e,"Invalid location in the log pane specified for log record insertion!");
      }
      log.setCaretPosition(log.getDocument().getLength());
      if (level.intValue() < Level.CONFIG.intValue()) {
        int progressLevel=5 - level.intValue() / 100;
        if (message != null) {
          messageStack.get(progressLevel).push(message);
          setProgress(null,level);
        }
 else {
          if (messageStack.get(progressLevel).isEmpty())           messageStack.get(progressLevel).pop();
          setProgress(0d,level);
        }
      }
 else       if (level.intValue() > Level.CONFIG.intValue())       if (systray != null) {
        MessageType type=MessageType.INFO;
        if (level.equals(Level.WARNING))         type=MessageType.WARNING;
 else         if (level.equals(Level.SEVERE))         type=MessageType.ERROR;
        systray.displayMessage(level.getLocalizedName(),message,type);
      }
    }
  }
);
}
 

Example 68

From project OpenEMRConnect, under directory /oeclib/src/main/java/ke/go/moh/oec/lib/.

Source file: LoggingServiceHandler.java

  19 
vote

/** 
 * Publishes a LogRecord. <p> The logging request was made initially to a Logger object, which initialized the LogRecord and forwarded it here. We send the record off to the Logging Server (if it is important enough.) <p> Programming note: we want to avoid recursion if anything is logged while we are sending the log record to the Logging Server. In that case, we don't want to try sending this message to the Logging Server also (stack overflow!) To prevent recursion, we look at the stack to see if we are on it. More precisely, we start from the third element of the stack -- because the first element is always from the Thread.getStackTrace() method, and the second elements is always from us, as the caller of Thread.getStackTrace(). But if we appear again at a higher level of the stack trace, that means that we have called ourselves recursively. If this happens we will not try to send the message to the Logging Server.
 * @param record description of the log event
 */
@Override public void publish(LogRecord record){
  if (isLoggable(record) && record.getLevel().intValue() >= Level.INFO.intValue()) {
    StackTraceElement[] stackTrace=Thread.currentThread().getStackTrace();
    for (int i=2; i < stackTrace.length; i++) {
      StackTraceElement e=stackTrace[i];
      if (e.getClassName().equals(LoggingServiceHandler.class.getName())) {
        return;
      }
    }
    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);
    mediator.getData(RequestTypeId.LOG_ENTRY,le);
  }
}
 

Example 69

From project org.ops4j.pax.logging, under directory /pax-logging-logback/src/main/java/org/ops4j/pax/logging/logback/internal/.

Source file: JdkHandler.java

  19 
vote

/** 
 * Publish a <tt>LogRecord</tt>. <p> The logging request was made initially to a <tt>Logger</tt> object, which initialized the <tt>LogRecord</tt> and forwarded it here. <p> The <tt>Handler</tt>  is responsible for formatting the message, when and if necessary.  The formatting should include localization.
 * @param record description of the log event
 */
public void publish(LogRecord record){
  Level level=record.getLevel();
  String loggerName=record.getLoggerName();
  Bundle callerBundle=getCallerBundle();
  String fqcn=java.util.logging.Logger.class.getName();
  PaxLogger logger=m_logService.getLogger(callerBundle,loggerName,fqcn);
  String message;
  try {
    message=getFormatter().formatMessage(record);
  }
 catch (  Exception ex) {
    message=record.getMessage();
  }
  Throwable throwable=record.getThrown();
  int levelInt=level.intValue();
  if (levelInt <= Level.FINEST.intValue())   logger.trace(message,throwable);
 else   if (levelInt <= Level.FINE.intValue())   logger.debug(message,throwable);
 else   if (levelInt <= Level.INFO.intValue())   logger.inform(message,throwable);
 else   if (levelInt <= Level.WARNING.intValue())   logger.warn(message,throwable);
 else   logger.error(message,throwable);
}
 

Example 70

From project orientdb, under directory /commons/src/main/java/com/orientechnologies/common/log/.

Source file: OLogFormatter.java

  19 
vote

@Override public String format(final LogRecord record){
  if (record.getThrown() == null)   return record.getMessage();
  final StringBuilder buffer=new StringBuilder();
  buffer.append(record.getMessage());
  Throwable current=record.getThrown();
  while (current != null) {
    buffer.append("\n" + current.getMessage());
    for (    StackTraceElement stackTraceElement : record.getThrown().getStackTrace()) {
      buffer.append("\n-> ");
      buffer.append(stackTraceElement.toString());
    }
    current=current.getCause();
  }
  return buffer.toString();
}
 

Example 71

From project osgi-tests, under directory /test-support/base/src/main/java/org/ancoron/osgi/test/.

Source file: TestLogFormatter.java

  19 
vote

@Override public String format(LogRecord record){
  StringBuilder sb=new StringBuilder();
  sb.append(dateFormat.format(new Date(record.getMillis())));
  final Level level=record.getLevel();
switch (level.intValue()) {
case LVL_INFO:
case LVL_FINE:
    sb.append("[   ");
  break;
case LVL_FINER:
sb.append("[  ");
break;
case LVL_FINEST:
case LVL_CONFIG:
case LVL_SEVERE:
sb.append("[ ");
break;
case LVL_WARNING:
sb.append("[");
break;
default :
break;
}
sb.append(level.getName()).append("] ");
final Object[] params=record.getParameters();
if (params != null && params.length > 0) {
sb.append(MessageFormat.format(record.getMessage(),params));
}
 else {
sb.append(record.getMessage());
}
sb.append("\n");
return sb.toString();
}
 

Example 72

From project OWASP-WebScarab, under directory /src/org/owasp/webscarab/util/swing/.

Source file: DocumentHandler.java

  19 
vote

public void publish(LogRecord record){
  if (!isLoggable(record)) {
    return;
  }
  final String msg;
  try {
    msg=getFormatter().format(record);
  }
 catch (  Exception ex) {
    reportError(null,ex,ErrorManager.FORMAT_FAILURE);
    return;
  }
  Runnable r=new Runnable(){
    public void run(){
      try {
        makeSpace(msg.length());
        _doc.insertString(_doc.getLength(),msg,null);
      }
 catch (      Exception ex) {
        reportError(null,ex,ErrorManager.WRITE_FAILURE);
      }
    }
  }
;
  if (SwingUtilities.isEventDispatchThread()) {
    r.run();
  }
 else {
    SwingUtilities.invokeLater(r);
  }
}
 

Example 73

From project seamless, under directory /swing/src/main/java/org/seamless/swing/logging/.

Source file: LoggingHandler.java

  19 
vote

protected String getSource(LogRecord record){
  StringBuilder sb=new StringBuilder(180);
  String[] split=record.getSourceClassName().split("\\.");
  if (split.length > sourcePathElements) {
    split=Arrays.copyOfRange(split,split.length - sourcePathElements,split.length);
  }
  for (  String s : split) {
    sb.append(s).append(".");
  }
  sb.append(record.getSourceMethodName());
  return sb.toString();
}
 

Example 74

From project selenium-client-factory, under directory /selenium-embedded-rc-driver/src/test/java/com/saucelabs/selenium/client/logging/.

Source file: LoggingSeleniumTest.java

  19 
vote

public void testSelenium(){
  Selenium s=SeleniumFactory.create("log:embedded-rc:*firefox","http://www.google.com/");
  LoggingSelenium ls=(LoggingSelenium)s;
  Logger l=Logger.getAnonymousLogger();
  ls.setLogger(l);
  l.addHandler(new Handler(){
    @Override public void publish(    LogRecord record){
      logs.add(record);
    }
    @Override public void flush(){
    }
    @Override public void close() throws SecurityException {
    }
  }
);
  s.start();
  s.open("http://www.google.com/");
  assertEquals("Google",s.getTitle());
  s.stop();
  verifyLog();
}
 

Example 75

From project skmclauncher, under directory /src/main/java/com/sk89q/mclauncher/launch/.

Source file: GameLauncher.java

  19 
vote

private static void redirectLogger(){
  Logger rootLogger=Logger.getLogger("");
  for (  Handler handler : rootLogger.getHandlers()) {
    rootLogger.removeHandler(handler);
  }
  rootLogger.addHandler(new Handler(){
    @Override public void publish(    LogRecord record){
      Level level=record.getLevel();
      Throwable t=record.getThrown();
      PrintStream out;
      if (t != null || level == Level.SEVERE || level == Level.WARNING) {
        out=System.err;
      }
 else {
        out=System.out;
      }
      out.println(record.getMessage());
      if (t != null) {
        t.printStackTrace(out);
      }
      out.flush();
    }
    @Override public void flush(){
    }
    @Override public void close() throws SecurityException {
    }
  }
);
}
 

Example 76

From project SOAj, under directory /soaj-core/src/main/java/info/soaj/core/formatter/.

Source file: SjcBasicLogFormatter.java

  19 
vote

/** 
 * Formats the given log record and returns the formatted <code>String</code>.
 * @param logRecord <code>LogRecord</code> objects are used to pass logging requests between the logging framework and individual log <code>Handler</code>s.
 * @return String - A formatted message.
 */
@Override public String format(final LogRecord logRecord){
  final String Method_Name="format";
  if (null == logRecord.getThrown()) {
    try {
      return logRecord.getMessage() + SjcConstant.NEW_LINE;
    }
 catch (    final Exception e) {
      throw new SjcFormatEPC(new SjcExceptionPathPO(SjcBasicLogFormatter.CLASS_NAME,Method_Name),"The log statement message could not be formatted.",e);
    }
  }
  return formatThrowableLogging(logRecord);
}
 

Example 77

From project Sone, under directory /src/main/java/net/pterodactylus/sone/main/.

Source file: SonePlugin.java

  19 
vote

@Override public void logged(LogRecord logRecord){
  Class<?> loggerClass=Logging.getLoggerClass(logRecord.getLoggerName());
  int recordLevel=logRecord.getLevel().intValue();
  if (recordLevel < Level.FINE.intValue()) {
    freenet.support.Logger.debug(loggerClass,logRecord.getMessage(),logRecord.getThrown());
  }
 else   if (recordLevel < Level.INFO.intValue()) {
    freenet.support.Logger.minor(loggerClass,logRecord.getMessage(),logRecord.getThrown());
  }
 else   if (recordLevel < Level.WARNING.intValue()) {
    freenet.support.Logger.normal(loggerClass,logRecord.getMessage(),logRecord.getThrown());
  }
 else   if (recordLevel < Level.SEVERE.intValue()) {
    freenet.support.Logger.warning(loggerClass,logRecord.getMessage(),logRecord.getThrown());
  }
 else {
    freenet.support.Logger.error(loggerClass,logRecord.getMessage(),logRecord.getThrown());
  }
}
 

Example 78

From project Sourcerer, under directory /infrastructure/utils/utilities/src/edu/uci/ics/sourcerer/util/io/logging/.

Source file: Logging.java

  19 
vote

public synchronized static Set<String> initializeResumeLogger(){
  if (resumeLoggingInitialized) {
    throw new IllegalStateException("Resume logging may only be initialized once");
  }
 else   if (!loggingInitialized) {
    throw new IllegalStateException("Logging must be initialized before resume logging");
  }
  if (OUTPUT.hasValue()) {
    File resumeFile=new File(OUTPUT.getValue(),command.getName() + "/" + RESUME_LOG.getValue());
    if (CLEAR_RESUME_LOG.getValue()) {
      if (resumeFile.exists()) {
        resumeFile.delete();
      }
    }
    Set<String> resumeSet=getResumeSet(resumeFile);
    try {
      FileHandler resumeHandler=new FileHandler(resumeFile.getPath(),true);
      resumeHandler.setLevel(RESUME);
      resumeHandler.setFormatter(new Formatter(){
        @Override public String format(        LogRecord record){
          return record.getMessage() + "\n";
        }
      }
);
      logger.addHandler(resumeHandler);
    }
 catch (    IOException e) {
      e.printStackTrace();
      System.exit(1);
    }
    resumeLoggingInitialized=true;
    return resumeSet;
  }
 else {
    return Collections.emptySet();
  }
}
 

Example 79

From project Spout, under directory /src/main/java/org/spout/engine/chat/console/.

Source file: ConsoleManager.java

  19 
vote

@Override public void publish(LogRecord record){
  ChatArguments args=LOG_TEMPLATE.getArguments();
  ChatArguments level=colorizeLevel(record.getLevel());
  args.setPlaceHolder(LEVEL,level);
  args.setPlaceHolder(MESSAGE,new ChatArguments(getFormatter().formatMessage(record)));
  console.addMessage(args);
  if (record.getThrown() != null) {
    StringWriter writer=new StringWriter();
    record.getThrown().printStackTrace(new PrintWriter(writer));
    String[] lines=writer.getBuffer().toString().split("\n");
    for (    String line : lines) {
      console.addMessage(LOG_TEMPLATE.getArguments().setPlaceHolder(LEVEL,level).setPlaceHolder(MESSAGE,new ChatArguments(line)));
    }
  }
}
 

Example 80

From project SpoutcraftLauncher, under directory /src/main/java/org/spoutcraft/launcher/entrypoint/.

Source file: SpoutcraftLauncher.java

  19 
vote

@Override public String format(LogRecord record){
  StringBuilder builder=new StringBuilder();
  builder.append(date.format(record.getMillis()));
  builder.append(" [");
  builder.append(record.getLevel().getLocalizedName().toUpperCase());
  builder.append("] ");
  builder.append(formatMessage(record));
  builder.append('\n');
  if (record.getThrown() != null) {
    StringWriter writer=new StringWriter();
    record.getThrown().printStackTrace(new PrintWriter(writer));
    builder.append(writer.toString());
  }
  return builder.toString();
}
 

Example 81

From project syncany, under directory /syncany/src/org/syncany/logging/.

Source file: LogFormatter.java

  19 
vote

@Override public String format(LogRecord record){
  StringBuilder sb=new StringBuilder();
  sb.append(dateFormat.format(new Date(record.getMillis())));
  sb.append(" | ");
  sb.append(String.format("%-10s",Config.getInstance().getMachineName()));
  sb.append(" | ");
  sb.append(String.format("%-20s",record.getLoggerName()));
  sb.append(" | ");
  sb.append(String.format("%-18s",Thread.currentThread().getName()));
  sb.append(" | ");
  sb.append(String.format("%-8s",record.getLevel().getName()));
  sb.append(" : ");
  sb.append(formatMessage(record));
  sb.append("\n");
  if (record.getThrown() != null) {
    sb.append(StringUtil.getStackTrace(record.getThrown()));
  }
  return sb.toString();
}
 

Example 82

From project traccar, under directory /src/org/traccar/.

Source file: Server.java

  19 
vote

/** 
 * Initialize logger
 */
private void initLogger(Properties properties) throws IOException {
  loggerEnabled=Boolean.valueOf(properties.getProperty("logger.enable"));
  if (loggerEnabled) {
    String fileName=properties.getProperty("logger.file");
    if (fileName != null) {
      FileHandler file=new FileHandler(fileName,true);
      file.setFormatter(new Formatter(){
        private final String LINE_SEPARATOR=System.getProperty("line.separator","\n");
        private final DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        public String format(        LogRecord record){
          String line=dateFormat.format(new Date(record.getMillis()));
          line+=" " + record.getLevel().getName() + ": ";
          line+=formatMessage(record);
          line+=LINE_SEPARATOR;
          return line;
        }
      }
);
      Log.getLogger().setLevel(Level.ALL);
      Log.getLogger().addHandler(file);
    }
  }
}
 

Example 83

From project turmeric-releng, under directory /support/turmeric-junit/src/main/java/org/ebayopensource/turmeric/junit/logging/.

Source file: SimpleConsoleHandler.java

  19 
vote

@Override public void publish(LogRecord record){
  StringBuilder buf=new StringBuilder();
  buf.append("[").append(record.getLevel().getName());
  buf.append("] ").append(record.getLoggerName());
  buf.append(" (").append(record.getSourceMethodName());
  buf.append("): ").append(record.getMessage());
  System.out.println(buf.toString());
  if (record.getThrown() != null) {
    record.getThrown().printStackTrace(System.out);
  }
}
 

Example 84

From project utils_1, under directory /src/main/java/net/pterodactylus/util/logging/.

Source file: Logging.java

  19 
vote

/** 
 * Initializes console logging.
 */
public static void setupConsoleLogging(){
  Logger rootLogger=getRootLogger();
  consoleHandler.setLevel(Level.ALL);
  consoleHandler.setFormatter(new Formatter(){
    private StringBuffer recordBuffer=new StringBuffer();
    private DateFormat dateFormatter=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS Z");
    /** 
 * {@inheritDoc}
 */
    @Override public synchronized String format(    LogRecord record){
      recordBuffer.setLength(0);
      String linePrefix=dateFormatter.format(new Date(record.getMillis())) + " [" + record.getLevel()+ "] ["+ Thread.currentThread().getName()+ "] ["+ record.getSourceClassName()+ "."+ record.getSourceMethodName()+ "] ";
      recordBuffer.append(linePrefix).append(String.format(record.getMessage(),record.getParameters())).append('\n');
      if (record.getThrown() != null) {
        Throwable throwable=record.getThrown();
        boolean causedBy=false;
        while (throwable != null) {
          recordBuffer.append(linePrefix);
          if (causedBy) {
            recordBuffer.append("caused by: ");
          }
          recordBuffer.append(throwable.getClass().getName());
          if (throwable.getMessage() != null) {
            recordBuffer.append(": ").append(throwable.getMessage());
          }
          recordBuffer.append("\n");
          StackTraceElement[] stackTraceElements=throwable.getStackTrace();
          for (          StackTraceElement stackTraceElement : stackTraceElements) {
            recordBuffer.append(linePrefix).append("  at ").append(stackTraceElement.getClassName()).append('.').append(stackTraceElement.getMethodName()).append("(").append(stackTraceElement.getFileName()).append(':').append(stackTraceElement.getLineNumber()).append(')').append("\n");
          }
          throwable=throwable.getCause();
          causedBy=true;
        }
      }
      return recordBuffer.toString();
    }
  }
);
  rootLogger.addHandler(consoleHandler);
}
 

Example 85

From project Vega, under directory /platform/com.subgraph.vega.application/src/com/subgraph/vega/application/logging/.

Source file: LogFormatter.java

  19 
vote

@Override public synchronized String format(LogRecord record){
  StringBuilder sb=new StringBuilder();
  dat.setTime(record.getMillis());
  args[0]=dat;
  StringBuffer text=new StringBuffer();
  if (formatter == null) {
    formatter=new MessageFormat(format);
  }
  formatter.format(args,text,null);
  sb.append(text);
  sb.append(" [");
  sb.append(record.getLevel().getLocalizedName());
  sb.append("] (");
  sb.append(record.getLoggerName());
  sb.append(") ");
  sb.append(formatMessage(record));
  sb.append("\n");
  if (record.getThrown() != null) {
    try {
      StringWriter sw=new StringWriter();
      PrintWriter pw=new PrintWriter(sw);
      record.getThrown().printStackTrace(pw);
      pw.close();
      sb.append(sw.toString());
    }
 catch (    Exception ex) {
      sb.append("Exception caused by writing exception backtrace to message!  : " + ex.getMessage());
    }
  }
  return sb.toString();
}
 

Example 86

From project vert.x, under directory /vertx-core/src/main/java/org/vertx/java/core/logging/impl/.

Source file: VertxLoggerFormatter.java

  19 
vote

@Override public String format(final LogRecord record){
  Date date=new Date();
  SimpleDateFormat dateFormat=new SimpleDateFormat("HH:mm:ss,SSS");
  StringBuffer sb=new StringBuffer();
  date.setTime(record.getMillis());
  sb.append("[").append(Thread.currentThread().getName()).append("] ");
  sb.append(dateFormat.format(date)).append(" ");
  sb.append(record.getLevel()).append(" [");
  sb.append(record.getLoggerName()).append("]").append("  ");
  sb.append(record.getMessage());
  sb.append(VertxLoggerFormatter.LINE_SEPARATOR);
  if (record.getThrown() != null) {
    try {
      StringWriter sw=new StringWriter();
      PrintWriter pw=new PrintWriter(sw);
      record.getThrown().printStackTrace(pw);
      pw.close();
      sb.append(sw.toString());
    }
 catch (    Exception ex) {
    }
  }
  return sb.toString();
}
 

Example 87

From project worldedit, under directory /src/main/java/com/sk89q/worldedit/.

Source file: LogFormat.java

  19 
vote

@Override public String format(LogRecord record){
  StringBuilder text=new StringBuilder();
  Level level=record.getLevel();
  if (level == Level.FINEST) {
    text.append("[FINEST] ");
  }
 else   if (level == Level.FINER) {
    text.append("[FINER] ");
  }
 else   if (level == Level.FINE) {
    text.append("[FINE] ");
  }
 else   if (level == Level.INFO) {
    text.append("[INFO] ");
  }
 else   if (level == Level.WARNING) {
    text.append("[WARNING] ");
  }
 else   if (level == Level.SEVERE) {
    text.append("[SEVERE] ");
  }
  text.append(record.getMessage());
  text.append("\r\n");
  Throwable t=record.getThrown();
  if (t != null) {
    StringWriter writer=new StringWriter();
    t.printStackTrace(new PrintWriter(writer));
    text.append(writer.toString());
  }
  return text.toString();
}
 

Example 88

From project xnio_1, under directory /api/src/test/java/org/xnio/.

Source file: IoUtilsTestCase.java

  19 
vote

public void testSafeCloseHandler() throws IOException {
  IoUtils.safeClose(new Handler(){
    public void close(){
      throw new RuntimeException("This error should be consumed but logged");
    }
    @Override public void publish(    LogRecord record){
    }
    @Override public void flush(){
    }
  }
);
  IoUtils.safeClose(new Handler(){
    public void close(){
      throw new Error("This error should be consumed but logged");
    }
    @Override public void publish(    LogRecord record){
    }
    @Override public void flush(){
    }
  }
);
  IoUtils.safeClose(new Handler(){
    public void close() throws SecurityException {
      throw new SecurityException("This error should be consumed but logged");
    }
    @Override public void publish(    LogRecord record){
    }
    @Override public void flush(){
    }
  }
);
  IoUtils.safeClose((Handler)null);
}
 

Example 89

From project xqsync, under directory /src/java/com/marklogic/ps/.

Source file: OneLineFormatter.java

  19 
vote

/** 
 * Format the given LogRecord. <p> This method can be overridden in a subclass. It is recommended to use the  {@link Formatter#formatMessage}convenience method to localize and format the message field.
 * @param record the log record to be formatted.
 * @return a formatted log record
 */
public synchronized String format(LogRecord record){
  StringBuffer sb=new StringBuffer();
  dat.setTime(record.getMillis());
  formatter.format(dat,sb,pos);
  sb.append(" ");
  String message=formatMessage(record);
  sb.append(record.getLevel().getLocalizedName());
  sb.append(": ");
  sb.append(message);
  sb.append(lineSeparator);
  if (record.getThrown() != null) {
    try {
      StringWriter sw=new StringWriter();
      PrintWriter pw=new PrintWriter(sw);
      record.getThrown().printStackTrace(pw);
      pw.close();
      sb.append(sw.toString());
    }
 catch (    Exception ex) {
    }
  }
  return sb.toString();
}
 

Example 90

From project zxing, under directory /zxingorg/src/com/google/zxing/web/.

Source file: ServletContextLogHandler.java

  19 
vote

@Override public void publish(LogRecord record){
  Formatter formatter=getFormatter();
  String message;
  if (formatter == null) {
    message=record.getMessage();
  }
 else {
    message=formatter.format(record);
  }
  Throwable throwable=record.getThrown();
  if (throwable == null) {
    context.log(message);
  }
 else {
    context.log(message,throwable);
  }
}
 

Example 91

From project zxing-iphone, under directory /zxingorg/src/com/google/zxing/web/.

Source file: ServletContextLogHandler.java

  19 
vote

@Override public void publish(LogRecord record){
  Formatter formatter=getFormatter();
  String message;
  if (formatter == null) {
    message=record.getMessage();
  }
 else {
    message=formatter.format(record);
  }
  Throwable throwable=record.getThrown();
  if (throwable == null) {
    context.log(message);
  }
 else {
    context.log(message,throwable);
  }
}