Advertisement
GeneralGDA

LogCatHandler

May 18th, 2015
586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.74 KB | None | 0 0
  1. // if-else-if-... - переписать по вкусу
  2. public final class LogcatHandler extends Handler
  3. {
  4.  
  5.  @Override
  6.  public void publish(final LogRecord logRecord)
  7.  {
  8.    if (null == logRecord)
  9.    {
  10.      return;
  11.    }
  12.    final String message = (null == logRecord.getMessage() ? "" : logRecord.getMessage());
  13.    if (Level.SEVERE == logRecord.getLevel())
  14.    {
  15.      Log.e(logRecord.getLoggerName(), message);
  16.    }
  17.    else if (Level.WARNING == logRecord.getLevel())
  18.    {
  19.      Log.w(logRecord.getLoggerName(), message);
  20.    }
  21.    else
  22.    {
  23.      Log.i(logRecord.getLoggerName(), message);
  24.    }
  25.  }
  26.  
  27.  @Override
  28.  public void close()
  29.  {
  30.    // nothing to close
  31.  }
  32.  
  33.  @Override
  34.  public void flush()
  35.  {
  36.    // nothing to flush
  37.  }
  38.  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement