本文整理了Java中com.metamx.common.logger.Logger
类的一些代码示例,展示了Logger
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger
类的具体详情如下:
包路径:com.metamx.common.logger.Logger
类名称:Logger
暂无
代码示例来源:origin: com.metamx/emitter
switch (level) {
case TRACE:
if (log.isTraceEnabled()) {
log.trace(message, started.get());
if (log.isDebugEnabled()) {
log.debug(message, started.get());
if (log.isInfoEnabled()) {
log.info(message, started.get());
log.warn(message, started.get());
break;
case ERROR:
log.error(message, started.get());
break;
代码示例来源:origin: com.metamx/java-util
@Override
public void stop()
{
log.info("Stopping object[%s]", o);
try {
stopMethod.invoke(o);
}
catch (Exception e) {
log.error(e, "Unable to invoke stopMethod() on %s", o.getClass());
}
}
}
代码示例来源:origin: metamx/java-util
@Override
public void run()
{
try {
log.debug("Running %s (delay %s)", callable, delay);
if (callable.call() == Signal.REPEAT) {
log.debug("Rescheduling %s (delay %s)", callable, delay);
exec.schedule(this, delay.getMillis(), TimeUnit.MILLISECONDS);
} else {
log.debug("Stopped rescheduling %s (delay %s)", callable, delay);
}
}
catch (Throwable e) {
log.error(e, "Uncaught exception.");
}
}
},
代码示例来源:origin: com.metamx/server-metrics
@Override
public boolean doMonitor(ServiceEmitter emitter)
{
log.info("I am watching...");
return true;
}
}
代码示例来源:origin: io.druid.extensions/druid-rabbitmq
@Override
public void shutdownCompleted(ShutdownSignalException cause)
{
log.warn(cause, "Connection closed!");
}
}
代码示例来源:origin: com.metamx/java-util
public static void close(Closeable closeable)
{
if (closeable == null) {
return;
}
try {
closeable.close();
}
catch (IOException e) {
log.error(e, "IOException thrown while closing Closeable.");
}
}
}
代码示例来源:origin: metamx/java-util
@Override
public void channelDisconnected(ChannelHandlerContext context, ChannelStateEvent event) throws Exception
{
if (log.isDebugEnabled()) {
log.debug("[%s] Channel disconnected", requestDesc);
}
// response is non-null if we received initial chunk and then exception occurs
if (response != null) {
handler.exceptionCaught(response, new ChannelException("Channel disconnected"));
}
channel.close();
channelResourceContainer.returnResource();
if (!retVal.isDone()) {
log.warn("[%s] Channel disconnected before response complete", requestDesc);
retVal.setException(new ChannelException("Channel disconnected"));
}
context.sendUpstream(event);
}
代码示例来源:origin: metamx/java-util
@Override
public ClientResponse<InputStream> done(ClientResponse<InputStream> clientResponse)
{
synchronized (done) {
try {
// An empty byte array is put at the end to give the SequenceInputStream.close() as something to close out
// after done is set to true, regardless of the rest of the stream's state.
queue.put(ByteSource.empty().openStream());
log.debug("Added terminal empty stream");
}
catch (InterruptedException e) {
log.warn(e, "Thread interrupted while adding to queue");
Thread.currentThread().interrupt();
throw Throwables.propagate(e);
}
catch (IOException e) {
// This should never happen
log.wtf(e, "The empty stream threw an IOException");
throw Throwables.propagate(e);
}
finally {
log.debug("Done after adding %d bytes of streams", byteCount.get());
done.set(true);
}
}
return ClientResponse.<InputStream>finished(clientResponse.getObj());
}
代码示例来源:origin: metamx/java-util
@Test
public void testLegacyLogging()
{
final Logger log = new Logger(LoggerTest.class);
final Throwable throwable = new Throwable();
// These should show up in an IDE as deprecated, but shouldn't actually fail.
log.error("foo", throwable);
log.warn("foo", throwable);
}
}
代码示例来源:origin: com.n3twork.druid/druid-indexing-service
@Override
public void unregister(final String service)
{
log.info("Unregistering chat handler[%s]", service);
final ChatHandler handler = handlers.get(service);
if (handler == null) {
log.warn("handler[%s] not currently registered, ignoring.", service);
}
try {
serviceAnnouncer.unannounce(makeDruidNode(service));
}
catch (Exception e) {
log.warn(e, "Failed to unregister service[%s]", service);
}
handlers.remove(service, handler);
}
代码示例来源:origin: com.metamx/java-util
private static void awaitNextRetry(final Throwable e, final int nTry, final boolean quiet) throws InterruptedException
{
final long baseSleepMillis = 1000;
final long maxSleepMillis = 60000;
final double fuzzyMultiplier = Math.min(Math.max(1 + 0.2 * ThreadLocalRandom.current().nextGaussian(), 0), 2);
final long sleepMillis = (long) (Math.min(maxSleepMillis, baseSleepMillis * Math.pow(2, nTry - 1))
* fuzzyMultiplier);
if (quiet) {
log.debug(e, "Failed on try %d, retrying in %,dms.", nTry, sleepMillis);
} else {
log.warn(e, "Failed on try %d, retrying in %,dms.", nTry, sleepMillis);
}
Thread.sleep(sleepMillis);
}
}
代码示例来源:origin: com.metamx/java-util
public Map<String, Long> to(String key, Map<String, Long> curr)
{
final Map<String, Long> prev = prevs.put(key, curr);
if (prev != null) {
return subtract(curr, prev);
}
else {
log.debug("No previous data for key[%s]", key);
return null;
}
}
代码示例来源:origin: com.n3twork.druid/druid-server
@Override
public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams params)
{
// Display info about all available segments
final Set<DataSegment> availableSegments = coordinator.getAvailableDataSegments();
if (log.isDebugEnabled()) {
log.debug("Available DataSegments");
for (DataSegment dataSegment : availableSegments) {
log.debug(" %s", dataSegment);
}
}
return params.buildFromExisting()
.withAvailableSegments(availableSegments)
.build();
}
}
代码示例来源:origin: com.n3twork.druid/druid-server
log.info("Loading properties from %s", propertiesFile);
try {
fileProps.load(new InputStreamReader(stream, Charsets.UTF_8));
log.wtf(e, "This can only happen if the .exists() call lied. That's f'd up.");
代码示例来源:origin: metamx/java-util
@Test
public void testLogWithCrazyMessages()
{
final String message = "this % might %d kill %*.s the %s parser";
final Logger log = new Logger(LoggerTest.class);
log.warn(message);
}
代码示例来源:origin: metamx/java-util
@Override
public boolean isGood(ChannelFuture resource)
{
Channel channel = resource.awaitUninterruptibly().getChannel();
boolean isSuccess = resource.isSuccess();
boolean isConnected = channel.isConnected();
boolean isOpen = channel.isOpen();
if (log.isTraceEnabled()) {
log.trace("isGood = isSucess[%s] && isConnected[%s] && isOpen[%s]", isSuccess, isConnected, isOpen);
}
return isSuccess && isConnected && isOpen;
}
代码示例来源:origin: com.n3twork.druid/druid-server
@LifecycleStop
public void stop() throws IOException
{
synchronized (lock) {
if (childrenCache == null) {
return;
}
// This close() call actually calls shutdownNow() on the executor registered with the Cache object...
childrenCache.close();
childrenCache = null;
}
for (String containerKey : Lists.newArrayList(containers.keySet())) {
final ContainerHolder containerHolder = containers.remove(containerKey);
if (containerHolder == null) {
log.wtf("!? Got key[%s] from keySet() but it didn't have a value!?", containerKey);
} else {
// This close() call actually calls shutdownNow() on the executor registered with the Cache object...
containerHolder.getCache().close();
}
}
}
代码示例来源:origin: com.metamx/java-util
@Override
public boolean doMonitor(ServiceEmitter emitter)
{
log.info("I am watching...");
return true;
}
}
代码示例来源:origin: metamx/java-util
@Override
public void stop()
{
log.info("Stopping object[%s]", o);
try {
stopMethod.invoke(o);
}
catch (Exception e) {
log.error(e, "Unable to invoke stopMethod() on %s", o.getClass());
}
}
}
代码示例来源:origin: io.druid.extensions/druid-rabbitmq
@Override
public void shutdownCompleted(ShutdownSignalException cause)
{
log.warn(cause, "Channel closed!");
}
}
内容来源于网络,如有侵权,请联系作者删除!