org.opennms.core.logging.Logging类的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中org.opennms.core.logging.Logging类的一些代码示例,展示了Logging类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logging类的具体详情如下:
包路径:org.opennms.core.logging.Logging
类名称:Logging

Logging介绍

暂无

代码示例

代码示例来源:origin: OpenNMS/opennms

public static <T> T withPrefix(final String prefix, final Callable<T> callable) throws Exception {
  final Map<String, String> mdc = Logging.getCopyOfContextMap();
  try {
    Logging.putPrefix(prefix);
    return callable.call();
  } finally {
    Logging.setContextMap(mdc);
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public void run() {
    Logging.withPrefix(LOG4J_CATEGORY, () -> {
      try {
        scheduleExistingInterfaces();
      } finally {
        setSchedulingCompleted(true);
      }
    });
  }
};

代码示例来源:origin: OpenNMS/opennms

@Override
  public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
    try(Logging.MDCCloseable closeable = Logging.withPrefixCloseable("web")) {
      super.handle(target,baseRequest,request,response);
    }
  }
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public void run() {
    final Map<String, String> localMdc = Logging.getCopyOfContextMap();
    try {
      Logging.setContextMap(parentMdc);
      runnable.run();
    } finally {
      Logging.setContextMap(localMdc);
    }
  }
};

代码示例来源:origin: OpenNMS/opennms

public static MDCCloseable withPrefixCloseable(final String prefix) {
  final Map<String, String> mdc = Logging.getCopyOfContextMap();
  Logging.putPrefix(prefix);
  return new MDCCloseable(mdc);
}

代码示例来源:origin: OpenNMS/opennms

/**
 * The constructor for the RTCManager
 */
public RTCManager() {
  super("rtc");
  Logging.putPrefix("rtc");
}

代码示例来源:origin: org.opennms.core.ipc.rpc/org.opennms.core.ipc.rpc.camel

final Map<String, String> clientContextMap = Logging.getCopyOfContextMap();
  try (MDCCloseable mdc = Logging.withContextMapCloseable(clientContextMap)) {
  Logging.putPrefix(RpcClientFactory.LOG_PREFIX);

代码示例来源:origin: OpenNMS/opennms

/**
 * This is the main method of the class. An instance is normally enqueued on
 * the scheduler which checks its <code>isReady</code> method to determine
 * execution. If the instance is ready for execution then it is started with
 * it's own thread context to execute the query. The last step in the method
 * before it exits is to reschedule the interface.
 */
@Override
public void run() {
  Logging.withPrefix(Collectd.LOG4J_CATEGORY, () -> {
    Logging.putThreadContext("service", m_spec.getServiceName());
    Logging.putThreadContext("ipAddress", m_agent.getAddress().getHostAddress());
    Logging.putThreadContext("nodeId", Integer.toString(m_agent.getNodeId()));
    Logging.putThreadContext("nodeLabel", m_agent.getNodeLabel());
    Logging.putThreadContext("foreignSource", m_agent.getForeignSource());
    Logging.putThreadContext("foreignId", m_agent.getForeignId());
    doRun();
  });
}

代码示例来源:origin: OpenNMS/opennms

private PollStatus doRun(int timeout) {
  final Map<String, String> mdc = Logging.getCopyOfContextMap();
  try {
    Logging.putThreadContext("service", m_svcName);
    Logging.putThreadContext("ipAddress", getIpAddr());
    Logging.putThreadContext("nodeId", Integer.toString(getNodeId()));
    Logging.putThreadContext("nodeLabel", getNodeLabel());
    long startDate = System.currentTimeMillis();
    LOG.debug("Start Scheduled Poll of service {}", this);
    return status;
  } finally {
    Logging.setContextMap(mdc);

代码示例来源:origin: OpenNMS/opennms

public static Runnable preserve(final Runnable runnable) {
  final Map<String, String> parentMdc = Logging.getCopyOfContextMap();
  return new Runnable() {
    @Override
    public void run() {
      final Map<String, String> localMdc = Logging.getCopyOfContextMap();
      try {
        Logging.setContextMap(parentMdc);
        runnable.run();
      } finally {
        Logging.setContextMap(localMdc);
      }
    }
  };
}

代码示例来源:origin: OpenNMS/opennms

@Override
  public void close() {
    Logging.setContextMap(mdc);
  }
}

代码示例来源:origin: OpenNMS/opennms

private void setLogPrefix() {
  Logging.putPrefix(LOG4J_CATEGORY);
}

代码示例来源:origin: OpenNMS/opennms

public static MDCCloseable withContextMapCloseable(final Map<String, String> contextMap) {
  final Map<String, String> mdc = Logging.getCopyOfContextMap();
  Logging.setContextMap(contextMap);
  return new MDCCloseable(mdc);
}

代码示例来源:origin: OpenNMS/opennms

final Map<String, String> clientContextMap = Logging.getCopyOfContextMap();
  try (MDCCloseable mdc = Logging.withContextMapCloseable(clientContextMap)) {
  Logging.putPrefix(RpcClientFactory.LOG_PREFIX);

代码示例来源:origin: OpenNMS/opennms

final Map<String, String> loggingContext = Logging.getCopyOfContextMap();
ResponseHandler<S, T> responseHandler = new ResponseHandler<S, T>(future, module, rpcId,
    expirationTime, loggingContext);

代码示例来源:origin: OpenNMS/opennms

public static void withPrefix(final String prefix, final Runnable runnable) {
  final Map<String, String> mdc = Logging.getCopyOfContextMap();
  try {
    Logging.putPrefix(prefix);
    runnable.run();
  } finally {
    Logging.setContextMap(mdc);
  }
}

代码示例来源:origin: OpenNMS/opennms

private void log(final String msg, final Object... args) {
  Logging.withPrefix("instrumentation", new Runnable() {
    @Override public void run() {
      LOG.info(msg, args);
    }
  });
  
}

代码示例来源:origin: OpenNMS/opennms

private void setLogPrefix() {
  Logging.putPrefix(LOG4J_CATEGORY);
}

代码示例来源:origin: OpenNMS/opennms

@Override
  protected void doInTransactionWithoutResult(final TransactionStatus status) {
    try (MDCCloseable mdc = Logging.withPrefixCloseable(LOG_PREFIX)) {
      runnable.run();
      m_minionDao.flush();
    }
  }
});

代码示例来源:origin: OpenNMS/opennms

private Object getArgument(Argument arg) throws ClassNotFoundException, SecurityException, NoSuchMethodException, IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
  Class<?> argClass = Class.forName(arg.getType());
  Constructor<?> construct = argClass.getConstructor(new Class[] { String.class });
  Map<String,String> mdc = Logging.getCopyOfContextMap();
  try {
    return construct.newInstance(new Object[] { arg.getValue().orElse(null) });
  } finally {
    Logging.setContextMap(mdc);
  }
}

相关文章