Skip to content

Commit

Permalink
Merge pull request #29 from Netflix/dannyt/reload4j-compat
Browse files Browse the repository at this point in the history
Compatibility with latest reload4j releases
  • Loading branch information
DanielThomas committed Feb 6, 2023
2 parents 18f9702 + 0d93e5e commit 10488eb
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 40 deletions.
15 changes: 0 additions & 15 deletions .travis.yml

This file was deleted.

50 changes: 25 additions & 25 deletions src/main/java/com/netflix/blitz4j/AsyncAppender.java
Expand Up @@ -53,12 +53,12 @@
* Incoming events are first stored in a queue and then worker thread(s) takes
* the messages and writes it to the underlying appenders. This makes the
* logging of the messages efficient for the following reasons
*
*
* 1) Logging threads do not block until the event is written to the
* destination, but block only until the message is written to the queue which
* should be way faster than having to wait until it is written to the
* underlying destination
*
*
* 2) During log storms, the in-memory buffer overflows the message to another
* structure which logs just the summary and not each log message
* </p>
Expand All @@ -68,9 +68,9 @@
* configurable. The summary also starts dropping its entries when it stays
* there longer than 1 min which is configurable as well.
* </p>
*
*
* @author Karthik Ranganathan
*
*
*/
public class AsyncAppender extends AppenderSkeleton implements
AppenderAttachable {
Expand All @@ -97,7 +97,7 @@ public class AsyncAppender extends AppenderSkeleton implements
private Counter discardEventCounter;
private Counter putInBufferCounter;


public AsyncAppender() {
this.name = APPENDER_NAME;
}
Expand Down Expand Up @@ -133,7 +133,7 @@ public boolean equals(Object obj) {
/**
* Initialize the batcher that stores the messages and calls the underlying
* appenders.
*
*
* @param appenderName
* - The name of the appender for which the batcher is created
*/
Expand All @@ -153,7 +153,7 @@ public void process(List<LoggingEvent> objects) {

/**
* Process the logging events. This is called by the batcher.
*
*
* @param loggingEvents
* - The logging events to be written to the underlying appender
*/
Expand All @@ -162,7 +162,7 @@ private void processLoggingEvents(List<LoggingEvent> loggingEvents) {
// original appenders configuration may be available only after the
// complete
// log4j initialization.
while (appenders.getAllAppenders() == null) {
while (appenders.getAllAppenders() == null || (appenders != null && !appenders.getAllAppenders().hasMoreElements())) {
if ((batcher == null) || (batcher.isPaused())) {
try {
Thread.sleep(SLEEP_TIME_MS);
Expand Down Expand Up @@ -279,7 +279,7 @@ public void append(final LoggingEvent event) {
/**
* Sets the name of the underlying appender that is wrapped by this
* <code>AsyncAppender</code>
*
*
* @param name
* - The name of the underlying appender
*/
Expand Down Expand Up @@ -336,7 +336,7 @@ private Counter initAndRegisterCounter(String name) {
/**
* Save the thread local info of the event in the event itself for
* processing later.
*
*
* @param event
* - The logging event for which the information should be saved
*/
Expand All @@ -351,7 +351,7 @@ private void saveThreadLocalInfo(final LoggingEvent event) {

/**
* Puts the logging events to the in-memory buffer.
*
*
* @param event
* - The event that needs to be put in the buffer.
* @return - true, if the put was successful, false otherwise
Expand All @@ -378,7 +378,7 @@ private static final class LogSummary {

/**
* Create new instance.
*
*
* @param event
* event, may not be null.
*/
Expand All @@ -389,7 +389,7 @@ public LogSummary(final LoggingEvent event) {

/**
* Add discarded event to summary.
*
*
* @param event
* event, may not be null.
*/
Expand All @@ -399,7 +399,7 @@ public void add(final LoggingEvent event) {

/**
* Create event with summary information.
*
*
* @return new event.
*/
public LoggingEvent createEvent() {
Expand All @@ -419,7 +419,7 @@ public LoggingEvent createEvent() {

/*
* (non-Javadoc)
*
*
* @see org.apache.log4j.AppenderSkeleton#close()
*/
@Override
Expand All @@ -431,7 +431,7 @@ public void close() {

/*
* (non-Javadoc)
*
*
* @see org.apache.log4j.spi.AppenderAttachable#getAllAppenders()
*/
@Override
Expand All @@ -443,7 +443,7 @@ public Enumeration getAllAppenders() {

/*
* (non-Javadoc)
*
*
* @see
* org.apache.log4j.spi.AppenderAttachable#getAppender(java.lang.String)
*/
Expand All @@ -456,7 +456,7 @@ public Appender getAppender(final String name) {

/*
* (non-Javadoc)
*
*
* @see
* org.apache.log4j.spi.AppenderAttachable#isAttached(org.apache.log4j.Appender
* )
Expand All @@ -470,7 +470,7 @@ public boolean isAttached(final Appender appender) {

/*
* (non-Javadoc)
*
*
* @see org.apache.log4j.AppenderSkeleton#requiresLayout()
*/
@Override
Expand All @@ -480,7 +480,7 @@ public boolean requiresLayout() {

/*
* (non-Javadoc)
*
*
* @see org.apache.log4j.spi.AppenderAttachable#removeAllAppenders()
*/
@Override
Expand All @@ -492,7 +492,7 @@ public void removeAllAppenders() {

/*
* (non-Javadoc)
*
*
* @see
* org.apache.log4j.spi.AppenderAttachable#removeAppender(org.apache.log4j
* .Appender)
Expand All @@ -506,7 +506,7 @@ public void removeAppender(final Appender appender) {

/*
* (non-Javadoc)
*
*
* @see
* org.apache.log4j.spi.AppenderAttachable#removeAppender(java.lang.String)
*/
Expand All @@ -519,7 +519,7 @@ public void removeAppender(final String name) {

/*
* (non-Javadoc)
*
*
* @see
* org.apache.log4j.spi.AppenderAttachable#addAppender(org.apache.log4j.
* Appender)
Expand All @@ -535,9 +535,9 @@ public void addAppender(final Appender newAppender) {
public int getDiscadMapSize() {
return logSummaryMap.size();
}

@Override
public void doAppend(LoggingEvent event) {
this.append(event);
this.append(event);
}
}

0 comments on commit 10488eb

Please sign in to comment.