Skip to content

Commit

Permalink
Fixed code styles warns related to the couchbase appender.
Browse files Browse the repository at this point in the history
  • Loading branch information
Acarus committed Oct 6, 2016
1 parent fb3de14 commit cfc3a0e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
Expand Up @@ -40,6 +40,13 @@ public CouchbaseLogAppender() {
super(CouchbaseConfig.class);
}

/**
* Saves logs into a couchbase database.
*
* @param logEventPack logs
* @param header header
* @param listener log delivery listener
*/
@Override
public void doAppend(LogEventPack logEventPack, RecordHeader header, LogDeliveryCallback listener) {
if (!closed) {
Expand All @@ -52,8 +59,8 @@ public void doAppend(LogEventPack logEventPack, RecordHeader header, LogDelivery
LOG.debug("[{}] appended {} logs to couchbase bucket", getApplicationToken(), logEventPack.getEvents().size());
}
listener.onSuccess();
} catch (Exception e) {
LOG.error(MessageFormat.format("[{0}] Attempted to append logs failed due to internal error", getName()), e);
} catch (Exception ex) {
LOG.error(MessageFormat.format("[{0}] Attempted to append logs failed due to internal error", getName()), ex);
listener.onInternalError();
}
} else {
Expand All @@ -67,8 +74,8 @@ protected void initFromConfiguration(LogAppenderDto appender, CouchbaseConfig co
LOG.debug("Initializing new instance of Couchbase log appender");
try {
logEventDao = new LogEventCouchbaseDao(configuration);
} catch (Exception e) {
LOG.error("Failed to init Couchbase log appender: ", e);
} catch (Exception ex) {
LOG.error("Failed to init Couchbase log appender: ", ex);
}
}

Expand Down
Expand Up @@ -44,6 +44,9 @@ public final class LogEvent implements Serializable {
public LogEvent() {
}

/**
* All-args constructor.
*/
public LogEvent(RecordHeader header, LogEventDto dto) {
this.id = dto.getId();
this.header = header;
Expand Down
Expand Up @@ -37,11 +37,14 @@ public class LogEventCouchbaseDao implements LogEventDao {

private static final Logger LOG = LoggerFactory.getLogger(LogEventCouchbaseDao.class);

private final Random RANDOM = new Random();
private final Random random = new Random();

private CouchbaseClient couchbaseClient;
private CouchbaseTemplate couchbaseTemplate;

/**
* Instantiates the LogEventCouchbaseDao.
*/
public LogEventCouchbaseDao(CouchbaseConfig configuration) throws Exception {

List<CouchbaseServerUri> couchbaseUris = configuration.getCouchbaseServerUris();
Expand Down Expand Up @@ -81,7 +84,7 @@ public void close() {

private String getId(String id) {
if (id == null || id.length() == 0) {
id = new UUID(System.currentTimeMillis(), RANDOM.nextLong()).toString();
id = new UUID(System.currentTimeMillis(), random.nextLong()).toString();
}
return id;
}
Expand Down

0 comments on commit cfc3a0e

Please sign in to comment.