Java 类org.apache.log4j.Priority 实例源码

项目:n4js    文件:EclipseLogAppender.java   
private int mapLevel(Level level) {
    switch (level.toInt()) {
    case Priority.DEBUG_INT:
    case Priority.INFO_INT:
        return IStatus.INFO;

    case Priority.WARN_INT:
        return IStatus.WARNING;

    case Priority.ERROR_INT:
    case Priority.FATAL_INT:
        return IStatus.ERROR;

    default:
        return IStatus.INFO;
    }
}
项目:LightSIP    文件:LogWriter.java   
public void logStackTrace(int traceLevel) {
    if (needsLogging) {
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        StackTraceElement[] ste = new Exception().getStackTrace();
        // Skip the log writer frame and log all the other stack frames.
        for (int i = 1; i < ste.length; i++) {
            String callFrame = "[" + ste[i].getFileName() + ":"
                    + ste[i].getLineNumber() + "]";
            pw.print(callFrame);
        }
        pw.close();
        String stackTrace = sw.getBuffer().toString();
        Level level = this.getLevel(traceLevel);
        Priority priority = this.getLogPriority();
        if ( level.isGreaterOrEqual(priority)) {
            logger.log(level,stackTrace);
        }

    }
}
项目:dmaap-framework    文件:EcompLayoutTest.java   
@SuppressWarnings("deprecation")
@Test
public void testAutoPopulate ()
{
    final TestClock tc = new TestClock ( 1234567890123L );

    final EcompLayout layout = new EcompLayout ();
    MDC.put ( EcompFields.kBeginTimestampMs, Long.toString ( SaClock.now () ) );

    tc.forward ( 60*1000L );
    layout.format ( new LoggingEvent ( "foo.bar", Category.getRoot (), Priority.INFO, "foobar", null ) );

    assertEquals ( "2009-02-13T23:31:30.123+00:00", MDC.get ( EcompFields.kBeginTimestamp ) );
    assertEquals ( "2009-02-13T23:32:30.123+00:00", MDC.get ( EcompFields.kEndTimestamp ) );
    assertEquals ( "60000", MDC.get ( EcompFields.kElapsedTimeMs ) );
}
项目:zefiro    文件:LoggingOutputStream.java   
/**
 * Creates the LoggingOutputStream to flush to the given Category.
 * 
 * @param cat        the Category to write to
 * 
 * @param priority   the Priority to use when writing to the Category
 * 
 * @exception IllegalArgumentException
 *                   if cat == null or priority == null
 */
public LoggingOutputStream(Category cat, Priority priority)
throws IllegalArgumentException {
  if (cat == null) {
    throw new IllegalArgumentException("cat == null");
  }
  if (priority == null) {
    throw new IllegalArgumentException("priority == null");
  }

  this.priority = priority;
  category = cat;
  bufLength = DEFAULT_BUFFER_LENGTH;
  buf = new byte[DEFAULT_BUFFER_LENGTH];
  count = 0;
}
项目:carbondata    文件:StandardLogServiceTest_UT.java   
/**
 * @throws Exception
 */
@Before public void setUp() throws Exception {

  new MockUp<Category>() {
    @SuppressWarnings("unused")
    @Mock public boolean isDebugEnabled() {
      return true;
    }

    @SuppressWarnings("unused")
    @Mock public boolean isEnabledFor(Priority level) {
      return true;
    }

    @SuppressWarnings("unused")
    @Mock public boolean isInfoEnabled() {
      return true;
    }
  };

  logService = new StandardLogService(this.getClass().getName());
}
项目:intellij-ce-playground    文件:MessagePool.java   
@Nullable
public LogMessage addIdeFatalMessage(final IdeaLoggingEvent aEvent) {
  Object data = aEvent.getData();
  final LogMessage message = data instanceof LogMessage ? (LogMessage)data : new LogMessage(aEvent);
  if (myIdeFatals.size() < MAX_POOL_SIZE_FOR_FATALS) {
    if (myFatalsGrouper.addToGroup(message)) {
      return message;
    }
  } else if (myIdeFatals.size() == MAX_POOL_SIZE_FOR_FATALS) {
    String msg = DiagnosticBundle.message("error.monitor.too.many.errors");
    LogMessage tooMany = new LogMessage(new LoggingEvent(msg, Category.getRoot(), Priority.ERROR, null, new TooManyErrorsException()));
    myFatalsGrouper.addToGroup(tooMany);
    return tooMany;
  }
  return null;
}
项目:cacheonix-core    文件:EventDetails.java   
/**
 * Creates a new <code>EventDetails</code> instance.
 * @param aTimeStamp a <code>long</code> value
 * @param aPriority a <code>Priority</code> value
 * @param aCategoryName a <code>String</code> value
 * @param aNDC a <code>String</code> value
 * @param aThreadName a <code>String</code> value
 * @param aMessage a <code>String</code> value
 * @param aThrowableStrRep a <code>String[]</code> value
 * @param aLocationDetails a <code>String</code> value
 */
EventDetails(long aTimeStamp,
             Priority aPriority,
             String aCategoryName,
             String aNDC,
             String aThreadName,
             String aMessage,
             String[] aThrowableStrRep,
             String aLocationDetails)
{
    mTimeStamp = aTimeStamp;
    mPriority = aPriority;
    mCategoryName = aCategoryName;
    mNDC = aNDC;
    mThreadName = aThreadName;
    mMessage = aMessage;
    mThrowableStrRep = aThrowableStrRep;
    mLocationDetails = aLocationDetails;
}
项目:cacheonix-core    文件:LoggingEventTest.java   
/**
   * Tests LoggingEvent.getLocationInfo() when no FQCN is specified.
   * See bug 41186.
   */
public void testLocationInfoNoFQCN() {
    Category root = Logger.getRootLogger();
 Priority level = Level.INFO;
    LoggingEvent event =
      new LoggingEvent(
        null, root, 0L,  level, "Hello, world.", null);
    LocationInfo info = event.getLocationInformation();
 //
 //  log4j 1.2 returns an object, its layout doesn't check for nulls.
 //  log4j 1.3 returns a null.
 //
 assertNotNull(info);
 if (info != null) {
    assertEquals("?", info.getLineNumber());
 assertEquals("?", info.getClassName());
 assertEquals("?", info.getFileName());
 assertEquals("?", info.getMethodName());
 }
}
项目:cacheonix-core    文件:JListView.java   
public
   void run() {

     while(true) {
synchronized(this) {
  try {
    this.wait();
  } catch(Exception e) {
  }
}
for(int i = 0; i < burst; i++) {
  LoggingEvent event = new LoggingEvent("x", cat, Priority.DEBUG, 
                    "Message "+counter, null);

  event.getThreadName();    
  if(counter % 50 == 0) {
    //event.throwable = new Exception("hello "+counter);
  }
  counter++;
  view.add(event);
}
     }
   }
项目:c-logger    文件:LogView4JLoggingEvent.java   
/**
 * Extract a reference to the static icon name
 * @param levelInt the int value of the level
 * @return an icon name
 */
private String getIconName() {

    switch (level) {
        case Priority.DEBUG_INT: {
            return ICONS[0];
        }
        case Priority.INFO_INT: {
            return ICONS[1];
        }
        case Priority.WARN_INT: {
            return ICONS[2];
        }
        case Priority.ERROR_INT: {
            return ICONS[3];
        }
        case Priority.FATAL_INT: {
            return ICONS[4];
        }
    }

    return null;
}
项目:c-logger    文件:LogView4JLoggingEvent.java   
/**
 * Extract a reference to the static level strings
 * @param levelInt the int value of the level
 * @return a level string
 */
public String getLevelString() {

    switch (level) {
        case Priority.DEBUG_INT: {
            return LEVELS[0];
        }
        case Priority.INFO_INT: {
            return LEVELS[1];
        }
        case Priority.WARN_INT: {
            return LEVELS[2];
        }
        case Priority.ERROR_INT: {
            return LEVELS[3];
        }
        case Priority.FATAL_INT: {
            return LEVELS[4];
        }
    }

    return null;
}
项目:c-logger    文件:LogView4JLoggingEvent.java   
/**
 * Fecth a flag for the current level to enable quick determination in a set of level flags
 * @return the level flag for this log events level
 */
public int getLevelFlag() {
    switch (level) {
        case Priority.DEBUG_INT: {
            return LEVEL_DEBUG_FLAG;
        }
        case Priority.INFO_INT: {
            return LEVEL_INFO_FLAG;
        }
        case Priority.WARN_INT: {
            return LEVEL_WARN_FLAG;
        }
        case Priority.ERROR_INT: {
            return LEVEL_ERROR_FLAG;
        }
        case Priority.FATAL_INT: {
            return LEVEL_FATAL_FLAG;
        }
        default: {
            return 0;
        }
    }
}
项目:daq-eclipse    文件:EventDetails.java   
/**
 * Creates a new <code>EventDetails</code> instance.
 * @param aTimeStamp a <code>long</code> value
 * @param aPriority a <code>Priority</code> value
 * @param aCategoryName a <code>String</code> value
 * @param aNDC a <code>String</code> value
 * @param aThreadName a <code>String</code> value
 * @param aMessage a <code>String</code> value
 * @param aThrowableStrRep a <code>String[]</code> value
 * @param aLocationDetails a <code>String</code> value
 */
EventDetails(long aTimeStamp,
             Priority aPriority,
             String aCategoryName,
             String aNDC,
             String aThreadName,
             String aMessage,
             String[] aThrowableStrRep,
             String aLocationDetails)
{
    mTimeStamp = aTimeStamp;
    mPriority = aPriority;
    mCategoryName = aCategoryName;
    mNDC = aNDC;
    mThreadName = aThreadName;
    mMessage = aMessage;
    mThrowableStrRep = aThrowableStrRep;
    mLocationDetails = aLocationDetails;
}
项目:feathers-sdk    文件:SimpleLog4JLogSystem.java   
/**
 *  initializes the log system using the logfile argument
 */
private void internalInit( String logfile )
    throws Exception
{
    /*
     *  do it by our classname to avoid conflicting with anything else 
     *  that might be used...
     */

    logger = Category.getInstance(this.getClass().getName());
    logger.setAdditivity(false);

    /*
     * Priority is set for DEBUG becouse this implementation checks 
     * log level.
     */
    logger.setPriority(Priority.DEBUG);

    RollingFileAppender appender = new RollingFileAppender( new PatternLayout( "%d - %m%n"), logfile, true);

    appender.setMaxBackupIndex( 1 );

    appender.setMaximumFileSize( 100000 );

    logger.addAppender(appender);
}
项目:olat    文件:ThreadLocalAwareLogger.java   
/**
 * Logger worker method - does the actual checks whether the given message should be logged at the given priority - taking into account this logger's loglevel plus
 * the threadLocalLogLevel.
 * 
 * @param priority
 *            the priority at which the given message should be logged
 * @param message
 *            the message which should be logged (or not, depending on levels)
 */
private final void threadLocalAwareLog(String fQCN, Priority priority, Object message, Throwable t) {
    if (isForcedToLog(priority)) {

        final Appender forcedAppender = getForcedAppender();

        // force the logging and modify the log message (the latter might return the original message)
        if (forcedAppender != null) {
            // only call the forced appender
            forcedAppender.doAppend(new LoggingEvent(fQCN, this, priority, modifyLogMessage(message), t));
        } else {
            // go via the normal appenders
            forcedLog(fQCN, priority, modifyLogMessage(message), t);
        }

    } else {

        // else not forced to log - use default behaviour
        super.log(fQCN, priority, message, t);

    }
}
项目:olat    文件:ThreadLocalAwareLogger.java   
@Override
public void l7dlog(Priority priority, String key, Object[] params, Throwable t) {
    if (isForcedToLog(priority)) {
        // from super.l7dlog:
        String pattern = getResourceBundleString(key);
        String msg;
        if (pattern == null)
            msg = key;
        else
            msg = java.text.MessageFormat.format(pattern, params);

        final Appender forcedAppender = getForcedAppender();

        // force the logging and modify the log message (the latter might return the original message)
        if (forcedAppender != null) {
            // only call the forced appender
            forcedAppender.doAppend(new LoggingEvent(FQCN, this, priority, modifyLogMessage(msg), t));
        } else {
            // go via the normal appenders
            forcedLog(FQCN, priority, modifyLogMessage(msg), t);
        }

    } else {
        super.l7dlog(priority, key, params, t);
    }
}
项目:olat    文件:ThreadLocalAwareLogger.java   
/**
 * Logger worker method - does the actual checks whether the given message should be logged at the given priority - taking into account this logger's loglevel plus
 * the threadLocalLogLevel.
 * 
 * @param priority
 *            the priority at which the given message should be logged
 * @param message
 *            the message which should be logged (or not, depending on levels)
 */
private final void threadLocalAwareLog(String fQCN, Priority priority, Object message, Throwable t) {
    if (isForcedToLog(priority)) {

        final Appender forcedAppender = getForcedAppender();

        // force the logging and modify the log message (the latter might return the original message)
        if (forcedAppender != null) {
            // only call the forced appender
            forcedAppender.doAppend(new LoggingEvent(fQCN, this, priority, modifyLogMessage(message), t));
        } else {
            // go via the normal appenders
            forcedLog(fQCN, priority, modifyLogMessage(message), t);
        }

    } else {

        // else not forced to log - use default behaviour
        super.log(fQCN, priority, message, t);

    }
}
项目:olat    文件:ThreadLocalAwareLogger.java   
@Override
public void l7dlog(Priority priority, String key, Object[] params, Throwable t) {
    if (isForcedToLog(priority)) {
        // from super.l7dlog:
        String pattern = getResourceBundleString(key);
        String msg;
        if (pattern == null)
            msg = key;
        else
            msg = java.text.MessageFormat.format(pattern, params);

        final Appender forcedAppender = getForcedAppender();

        // force the logging and modify the log message (the latter might return the original message)
        if (forcedAppender != null) {
            // only call the forced appender
            forcedAppender.doAppend(new LoggingEvent(FQCN, this, priority, modifyLogMessage(msg), t));
        } else {
            // go via the normal appenders
            forcedLog(FQCN, priority, modifyLogMessage(msg), t);
        }

    } else {
        super.l7dlog(priority, key, params, t);
    }
}
项目:nabs    文件:EventDetails.java   
/**
 * Creates a new <code>EventDetails</code> instance.
 * @param aTimeStamp a <code>long</code> value
 * @param aPriority a <code>Priority</code> value
 * @param aCategoryName a <code>String</code> value
 * @param aNDC a <code>String</code> value
 * @param aThreadName a <code>String</code> value
 * @param aMessage a <code>String</code> value
 * @param aThrowableStrRep a <code>String[]</code> value
 * @param aLocationDetails a <code>String</code> value
 */
EventDetails(long aTimeStamp,
             Priority aPriority,
             String aCategoryName,
             String aNDC,
             String aThreadName,
             String aMessage,
             String[] aThrowableStrRep,
             String aLocationDetails)
{
    mTimeStamp = aTimeStamp;
    mPriority = aPriority;
    mCategoryName = aCategoryName;
    mNDC = aNDC;
    mThreadName = aThreadName;
    mMessage = aMessage;
    mThrowableStrRep = aThrowableStrRep;
    mLocationDetails = aLocationDetails;
}
项目:nabs    文件:JListView.java   
public
   void run() {

     while(true) {
synchronized(this) {
  try {
    this.wait();
  } catch(Exception e) {
  }
}
for(int i = 0; i < burst; i++) {
  LoggingEvent event = new LoggingEvent("x", cat, Priority.DEBUG, 
                    "Message "+counter, null);

  event.getThreadName();    
  if(counter % 50 == 0) {
    //event.throwable = new Exception("hello "+counter);
  }
  counter++;
  view.add(event);
}
     }
   }
项目:swift-k    文件:MonitorAppender.java   
private void addFilteredProcessors(StateUpdater updater, 
     Class<? extends FilteringProcessorDispatcher> dcls, 
     AbstractFilteringProcessor... ps) {
 Map<Priority, FilteringProcessorDispatcher> m = new HashMap<Priority, FilteringProcessorDispatcher>();

 for (AbstractFilteringProcessor p : ps) {
     Level l = p.getSupportedLevel();
     FilteringProcessorDispatcher d = m.get(l);
     if (d == null) {
         try {
                d = dcls.newInstance();
                d.setLevel(l);
                m.put(l, d);
                updater.addProcessor(d);
         }
         catch (Exception e) {
             throw new RuntimeException("Cannot instantiate dispatcher " + dcls, e);
         }
     }
     d.add(p);
 }      
}
项目:swift-k    文件:SwiftLogInfo.java   
private static Priority getLevel(String s) {
    if ("WARN".equals(s)) {
        return Level.WARN;
    }
    else if ("ERROR".equals(s)) {
        return Level.ERROR;
    }
    else if ("INFO".equals(s)) {
        return Level.INFO;
    }
    else if ("DEBUG".equals(s)) {
        return Level.DEBUG;
    }
    else {
        return Level.ALL;
    }
}
项目:coala    文件:CoalaLog4jLogger.java   
@Override
protected void forcedLog(final String fqcn, final Priority level,
        final Object message, final Throwable t)
{
    final String timePrefix = getTimePrefix();
    // System.err.println("3. time prefix: " + timePrefix + " for "
    // + getName());

    final String methodAffix = getMethodAffix();
    try
    {
        callAppenders(new LoggingEvent(fqcn, this, level,
                new StringBuilder(timePrefix).append(this.idPrefix)
                        .append(message).append(methodAffix).toString(), t));
    } catch (final Throwable e)
    {
        e.printStackTrace();
        callAppenders(new LoggingEvent(fqcn, this, level, message, t));
    }
}
项目:jpostgrey    文件:InputThread.java   
@Override
public void run() {

    try (OutputStreamWriter out = new OutputStreamWriter(
            socket.getOutputStream())) {
        log(Priority.INFO_INT, "New incoming connection");

        String resultString = findTripletAndBuildOutputRecord(createInputRecordFromSocket());

        out.flush();
        out.write(resultString);
        out.write(String.format("%n"));
        out.write(String.format("%n"));

    } catch (IOException e) {
        for (StackTraceElement element : e.getStackTrace()) {
            log(Priority.ERROR_INT, element.toString());
        }
    }
}
项目:jpostgrey    文件:InputThread.java   
private InputRecord createInputRecordFromSocket() throws IOException {
    String inputString;
    BufferedReader inFromClient = null;

    try {
        inFromClient = new BufferedReader(new InputStreamReader(
                socket.getInputStream()));
        InputRecordBuilder builder = new InputRecord.InputRecordBuilder();
        do {
            inputString = inFromClient.readLine();
            log(Priority.DEBUG_INT, "Got message '" + inputString + "'");
            if (inputString != null && !inputString.isEmpty()) {
                builder.addRow(inputString);
            }
        } while (inputString != null && !inputString.isEmpty());
        return builder.build();
    } catch (BuilderNotCompleteException e) {
        log(Priority.INFO_INT,
                "Not all records received ... have to reject");
    }

    return null;
}
项目:restcommander    文件:ANSIConsoleAppender.java   
/**
 * Get the appropriate control characters to change
 * the colour for the specified logging level.
 */
private String getColour(org.apache.log4j.Level level) {
    switch (level.toInt()) {
        case Priority.FATAL_INT:
            return FATAL_COLOUR;
        case Priority.ERROR_INT:
            return ERROR_COLOUR;
        case Priority.WARN_INT:
            return WARN_COLOUR;
        case Priority.INFO_INT:
            return INFO_COLOUR;
        case Priority.DEBUG_INT:
            return DEBUG_COLOUR;
        default:
            return TRACE_COLOUR;
    }
}
项目:tools-idea    文件:MessagePool.java   
@Nullable
public LogMessage addIdeFatalMessage(final IdeaLoggingEvent aEvent) {
  Object data = aEvent.getData();
  final LogMessage message = data instanceof LogMessage ? (LogMessage)data : new LogMessage(aEvent);
  if (myIdeFatals.size() < MAX_POOL_SIZE_FOR_FATALS) {
    if (myFatalsGrouper.addToGroup(message)) {
      return message;
    }
  } else if (myIdeFatals.size() == MAX_POOL_SIZE_FOR_FATALS) {
    String msg = DiagnosticBundle.message("error.monitor.too.many.errors");
    LogMessage tooMany = new LogMessage(new LoggingEvent(msg, Category.getRoot(), Priority.ERROR, null, new TooManyErrorsException()));
    myFatalsGrouper.addToGroup(tooMany);
    return tooMany;
  }
  return null;
}
项目:SimpleREST    文件:GroupResource.java   
@Get("json")
public String toJson(){
    GetOptions.allowAccess(getResponse());
    try{
        this.group = Group.find(context, groupId);
    }catch(Exception ex){
        log.log(Priority.INFO, ex);
    }finally{
        context.abort();
    }

    StubGroup stub = new StubGroup(this.group);

    Gson gson = new Gson();
    try{
        context.abort();
    }catch(NullPointerException e){
        log.log(Priority.INFO, e);
    }

    return gson.toJson(stub);
}
项目:SimpleREST    文件:CommunityResource.java   
@Get("json")
public String toJson(){
    Gson gson = new Gson();
    try{
        comm = Community.find(context, this.communityId);
    }catch(Exception e){
        if(context != null)
            context.abort();
        log.log(Priority.INFO, e, e);
    }finally{
        if(context != null)
            context.abort();
    }
    StubCommunity s = new StubCommunity(comm.getID(), comm.getName(), comm.getMetadata("short_description"),
                comm.getMetadata("introductory_text"), comm.getMetadata("copyright_text"), comm.getMetadata("side_bar_text"));
    return gson.toJson(s);
}
项目:SimpleREST    文件:RootCommunitiesResource.java   
@Get("json")
public String toJson() {
    GetOptions.allowAccess(getResponse());
    /*Community class from DSpace-api won't work for Serialization to json,
    so we use StubCommunity, and use a slow loop to create new StubCommunity array,
    which will be Serializable and converted to json. */
    Gson gson = new Gson();
    StubCommunity[] toJsonCommunities = new StubCommunity[communities.length];
    for(int i = 0; i < communities.length; i++){
        toJsonCommunities[i] = new StubCommunity(communities[i].getID(), communities[i].getName(), communities[i].getMetadata("short_description"),
                communities[i].getMetadata("introductory_text"), communities[i].getMetadata("copyright_text"), communities[i].getMetadata("side_bar_text"));
    }

    try{
        context.abort();
    }catch(Exception e){
        log.log(Priority.FATAL, e);
    }

    return gson.toJson(toJsonCommunities);
}
项目:ngcalsync    文件:Log4JSwingAppender.java   
private AttributeSet getAttributeSet(final LoggingEvent event) {
    final MutableAttributeSet attr = new SimpleAttributeSet();
    switch (event.getLevel().toInt()) {
        case Priority.DEBUG_INT:
            StyleConstants.setForeground(attr, Color.gray);
            break;
        case Priority.INFO_INT:
            StyleConstants.setForeground(attr, Color.black);
            break;
        case Priority.WARN_INT:
            StyleConstants.setForeground(attr, Color.orange.darker());
            break;
        case Priority.ERROR_INT:
            StyleConstants.setForeground(attr, Color.red);
            break;
        case Priority.FATAL_INT:
            StyleConstants.setForeground(attr, Color.red.darker());
            StyleConstants.setBold(attr, true);
            break;
        default:
            StyleConstants.setForeground(attr, Color.black);
    }
    return attr;
}
项目:kettle-trunk    文件:KettleLogChannelAppenderTest.java   
@Test
public void append_debug() {
  MockLoggingChannel log = new MockLoggingChannel();
  KettleLogChannelAppender appender = new KettleLogChannelAppender(log);
  Logger testLogger = Logger.getLogger(getClass());
  testLogger.setLevel(Level.ALL);

  // DEBUG messages should be interpreted as "debug" messages
  Layout layout = new Log4jKettleLayout();
  @SuppressWarnings("deprecation")
  LoggingEvent event = new LoggingEvent("org.test", testLogger, Priority.DEBUG, "debug test!", null);

  appender.doAppend(event);
  assertEquals(0, log.getBasicMessages().size());
  assertEquals(0, log.getDetailedMessages().size());
  assertEquals(0, log.getErrorMessages().size());
  assertEquals(0, log.getMinimalMessages().size());
  assertEquals(0, log.getRowLevelMessages().size());

  assertEquals(1, log.getDebugMessages().size());
  assertEquals(layout.format(event), log.getDebugMessages().get(0).getMessage());
}
项目:kettle-trunk    文件:KettleLogChannelAppenderTest.java   
@Test
public void append_trace() {
  MockLoggingChannel log = new MockLoggingChannel();
  KettleLogChannelAppender appender = new KettleLogChannelAppender(log);
  Logger testLogger = Logger.getLogger(getClass());
  testLogger.setLevel(Level.ALL);

  // TRACE logging events should be interpreted as "row level" messages
  Layout layout = new Log4jKettleLayout();
  @SuppressWarnings("deprecation")
  LoggingEvent event = new LoggingEvent("org.test", testLogger, Priority.toPriority(Level.TRACE_INT), "trace test!", null);

  appender.doAppend(event);
  assertEquals(0, log.getBasicMessages().size());
  assertEquals(0, log.getDetailedMessages().size());
  assertEquals(0, log.getErrorMessages().size());
  assertEquals(0, log.getMinimalMessages().size());
  assertEquals(0, log.getDebugMessages().size());

  assertEquals(1, log.getRowLevelMessages().size());
  assertEquals(layout.format(event), log.getRowLevelMessages().get(0).getMessage());
}
项目:kettle-trunk    文件:KettleLogChannelAppenderTest.java   
@Test
public void append_off() {
  MockLoggingChannel log = new MockLoggingChannel();
  KettleLogChannelAppender appender = new KettleLogChannelAppender(log);
  Logger testLogger = Logger.getLogger(getClass());
  testLogger.setLevel(Level.ALL);

  // OFF logging events should be interpreted as "minimal" messages
  Layout layout = new Log4jKettleLayout();
  @SuppressWarnings("deprecation")
  LoggingEvent event = new LoggingEvent("org.test", testLogger, Priority.toPriority(Level.OFF_INT), "off test!", null);

  appender.doAppend(event);
  assertEquals(0, log.getBasicMessages().size());
  assertEquals(0, log.getDetailedMessages().size());
  assertEquals(0, log.getErrorMessages().size());
  assertEquals(0, log.getRowLevelMessages().size());
  assertEquals(0, log.getDebugMessages().size());

  assertEquals(1, log.getMinimalMessages().size());
  assertEquals(layout.format(event), log.getMinimalMessages().get(0).getMessage());
}
项目:spliceengine    文件:SpliceLevel2OptimizerImpl.java   
@Override
@SuppressFBWarnings(value = "SF_SWITCH_NO_DEFAULT",justification = "Intentional")
public void trace(TraceLevel level, String traceString){

    Priority prio = Level.INFO;
    switch(level){
        case TRACE:
            prio =  Level.TRACE;
            break;
        case DEBUG:
            prio =  Level.DEBUG;
            break;
        case WARN:
            prio =  Level.WARN;
            break;
        case ERROR:
            prio =  Level.ERROR;
            break;
    }

    if (TRACE_LOGGER.isTraceEnabled()) {
        TRACE_LOGGER.log(prio,traceString);
    }
}
项目:consulo    文件:MessagePool.java   
@Nullable
public LogMessage addIdeFatalMessage(final IdeaLoggingEvent aEvent) {
  Object data = aEvent.getData();
  final LogMessage message = data instanceof LogMessage ? (LogMessage)data : new LogMessage(aEvent);
  if (myIdeFatals.size() < MAX_POOL_SIZE_FOR_FATALS) {
    if (myFatalsGrouper.addToGroup(message)) {
      return message;
    }
  } else if (myIdeFatals.size() == MAX_POOL_SIZE_FOR_FATALS) {
    String msg = DiagnosticBundle.message("error.monitor.too.many.errors");
    LogMessage tooMany = new LogMessage(new LoggingEvent(msg, Category.getRoot(), Priority.ERROR, null, new TooManyErrorsException()));
    myFatalsGrouper.addToGroup(tooMany);
    return tooMany;
  }
  return null;
}
项目:Omoikane    文件:CEAppender.java   
@Override
protected void append(final LoggingEvent event) {
    if ( event.getLevel().isGreaterOrEqual(Priority.WARN) ) {
        errorWindow(event);
    } else if(event.getLevel().isGreaterOrEqual(Priority.INFO)) {
        Toolkit.getDefaultToolkit().beep();
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                JOptionPane.showMessageDialog(null,
                        event.getMessage(),
                        "Información",
                        JOptionPane.INFORMATION_MESSAGE);
            }
        });

    } else if(Principal.DEBUG) {
        Toolkit.getDefaultToolkit().beep();
        JOptionPane.showMessageDialog(null,
                event.getMessage(),
                "Información de depuración",
                JOptionPane.INFORMATION_MESSAGE);
    }
}
项目:Omoikane    文件:JFXAppender.java   
@Override
protected void append(LoggingEvent event) {
    if ( event.getLevel().isGreaterOrEqual(Priority.ERROR) ) {
        Toolkit.getDefaultToolkit().beep();
        Dialog.showThrowable( "Error", event.getRenderedMessage(), event.getThrowableInformation().getThrowable());
    } else {
        Toolkit.getDefaultToolkit().beep();
        Dialog.showInfo( "Aviso", event.getRenderedMessage() );
    }
    /*
    System.out.println(event.getMessage());
    ExceptionWindow ew = new ExceptionWindow();
    ew.getLblTituloError().setText((String) event.getMessage());
    if(event.getThrowableInformation() != null) {
        ew.getTxtExcepcion().setText(Misc.getStackTraceString(event.getThrowableInformation().getThrowable()));
    }
    ew.setVisible(true);
    */
}
项目:LightSIP    文件:LogWriter.java   
public Priority getLogPriority() {
     if ( this.traceLevel == TRACE_INFO ) {
        return Priority.INFO;
    } else if ( this.traceLevel == TRACE_ERROR ) {
        return Priority.ERROR;
    } else if ( this.traceLevel == TRACE_DEBUG) {
        return Priority.DEBUG;
    } else if ( this.traceLevel == TRACE_TRACE) {
        return Priority.DEBUG;
    } else {
        return Priority.FATAL;
    }
}
项目:convertigo-engine    文件:LogWrapper.java   
@Override
public synchronized void writeToLog(int messageLogLevel, String message) {
    Priority priority = Level.TRACE;
    if (messageLogLevel == Log.LOGLEVEL_FATAL_ERROR) priority = Level.FATAL;
    else if (messageLogLevel == Log.LOGLEVEL_EXCEPTION) priority = Level.ERROR;
    else if (messageLogLevel == Log.LOGLEVEL_WARNING) priority = Level.WARN;
    else if (messageLogLevel == Log.LOGLEVEL_MESSAGE) priority = Level.INFO;
    else if (messageLogLevel == Log.LOGLEVEL_DEBUG) priority = Level.DEBUG;
    else if (messageLogLevel == Log.LOGLEVEL_DEBUG2) priority = Level.TRACE;
    else if (messageLogLevel == Log.LOGLEVEL_DEBUG3) priority = Level.TRACE;
    logger.log(priority, message);
}