From 6c76a88b06e4fe4568685699a59facd3ea9aa5c8 Mon Sep 17 00:00:00 2001 From: psquickitjayant Date: Tue, 4 Aug 2015 14:43:52 +0530 Subject: [PATCH 1/7] Updated LogglyClient.java for tag support --- .../github/tony19/loggly/LogglyClient.java | 380 +++++++++--------- 1 file changed, 201 insertions(+), 179 deletions(-) diff --git a/src/main/java/com/github/tony19/loggly/LogglyClient.java b/src/main/java/com/github/tony19/loggly/LogglyClient.java index b607d4a..d7cac41 100644 --- a/src/main/java/com/github/tony19/loggly/LogglyClient.java +++ b/src/main/java/com/github/tony19/loggly/LogglyClient.java @@ -18,6 +18,8 @@ import java.util.Arrays; import java.util.Collection; +import android.util.Log; + import retrofit.RestAdapter; import retrofit.RetrofitError; import retrofit.client.Response; @@ -25,186 +27,206 @@ /** * Loggly client - * + * * @author tony19@gmail.com */ public class LogglyClient implements ILogglyClient { - private static final String API_URL = "http://logs-01.loggly.com/"; - private final ILogglyRestService loggly; - private final String token; - private String tags; - - /** - * Creates a Loggly client - * @param token Loggly customer token - * http://loggly.com/docs/customer-token-authentication-token/ - */ - public LogglyClient(String token) { - if (token == null || token.isEmpty()) { - throw new IllegalArgumentException("token cannot be empty"); - } - - RestAdapter restAdapter = new RestAdapter.Builder() - .setEndpoint(API_URL) - .build(); - - this.token = token; - this.loggly = restAdapter.create(ILogglyRestService.class); - } - - /** - * Creates a Loggly client with the specified REST API. - * This is package private for internal testing only. - * @param token Loggly customer token - * @param restApi implementation of {@link ILogglyRestService} - */ - LogglyClient(String token, ILogglyRestService restApi) { - this.token = token; - this.loggly = restApi; - } - - /** - * Sets the tags to use for Loggly messages. The list of - * strings are converted into a single CSV (trailing/leading - * spaces stripped from each entry). - * @param tags CSV or list of tags - */ - public void setTags(String... tags) { - StringBuilder builder = new StringBuilder(); - boolean first = true; - for (String s : tags) { - for (String t : s.split(",")) { - t = t.trim(); - if (!t.isEmpty()) { - if (!first) { - builder.append(","); - } - builder.append(t); - } - first = false; - } - } - // "tags" field must be null for Retrofit to exclude Loggly tags header. - // Empty header string is not acceptable. - this.tags = builder.length() > 0 ? builder.toString() : null; - } - - /** - * Posts a log message to Loggly - * @param message message to be logged - * @return {@code true} if successful; {@code false} otherwise - */ - public boolean log(String message) { - if (message == null) return false; - - boolean ok; - try { - ok = loggly.log(token, tags, new TypedString(message)).isOk(); - } catch (Exception e) { - e.printStackTrace(); - ok = false; - } - return ok; - } - - /** - * Posts a log message asynchronously to Loggly - * @param message message to be logged - * @param callback callback to be invoked on completion of the post - */ - public void log(String message, final Callback callback) { - if (message == null) return; - - loggly.log(token, - tags, - new TypedString(message), - new retrofit.Callback() { - public void success(LogglyResponse logglyResponse, Response response) { - callback.success(); - } - - public void failure(RetrofitError retrofitError) { - callback.failure(retrofitError.getMessage()); - } - }); - } - - /** - * Posts several log messages in bulk to Loggly - * @param messages messages to be logged - * @return {@code true} if successful; {@code false} otherwise - */ - public boolean logBulk(String... messages) { - if (messages == null) return false; - return logBulk(Arrays.asList(messages)); - } - - /** - * Posts several log messages in bulk to Loggly - * @param messages messages to be logged - * @return {@code true} if successful; {@code false} otherwise - */ - public boolean logBulk(Collection messages) { - if (messages == null) return false; - - String parcel = joinStrings(messages); - if (parcel.isEmpty()) return false; - - boolean ok; - try { - ok = loggly.logBulk(token, tags, new TypedString(parcel)).isOk(); - } catch (Exception e) { - e.printStackTrace(); - ok = false; - } - return ok; - } - - /** - * Posts several log messages in bulk to Loggly asynchronously - * @param messages messages to be logged - * @param callback callback to be invoked on completion of the post - */ - public void logBulk(Collection messages, final Callback callback) { - if (messages == null) return; - - String parcel = joinStrings(messages); - if (parcel.isEmpty()) return; - - loggly.logBulk(token, - tags, - new TypedString(parcel), - new retrofit.Callback() { - public void success(LogglyResponse logglyResponse, Response response) { - callback.success(); - } - - public void failure(RetrofitError retrofitError) { - callback.failure(retrofitError.getMessage()); - } - }); - } - - /** - * Combines a collection of messages to be sent to Loggly. - * In order to preserve event boundaries, the new lines in - * each message are replaced with '\r', which get stripped - * by Loggly. - * @param messages messages to be combined - * @return a single string containing all the messages - */ - private String joinStrings(Collection messages) { - StringBuilder b = new StringBuilder(); - for (String s : messages) { - if (s == null || s.isEmpty()) { - continue; - } - - // Preserve new-lines in this event by replacing them - // with "\r". Otherwise, they're processed as event - // delimiters, resulting in unintentional multiple events. - b.append(s.replaceAll("[\r\n]", "\r")).append('\n'); - } - return b.toString(); - } + private static final String API_URL = "http://logs-01.loggly.com/"; + private ILogglyRestService loggly; + private String token; + static String tags = "android"; + + /** + * Creates a Loggly client + * @param token Loggly customer token + * http://loggly.com/docs/customer-token-authentication-token/tag/android + */ + public LogglyClient(String token) { + this(token, tags); + if (token == null || token.isEmpty()) { + throw new IllegalArgumentException("token cannot be empty"); + } + + RestAdapter restAdapter = new RestAdapter.Builder() + .setEndpoint(API_URL).build(); + + this.token = token; + this.loggly = restAdapter.create(ILogglyRestService.class); + } + + public LogglyClient(String token, String tag) { + if (token == null || token.isEmpty()) { + throw new IllegalArgumentException("token cannot be empty"); + } + + RestAdapter restAdapter = new RestAdapter.Builder() + .setEndpoint(API_URL).build(); + this.tags = tag; + this.token = token; + this.loggly = restAdapter.create(ILogglyRestService.class); + } + + /** + * Creates a Loggly client with the specified REST API. This is package + * private for internal testing only. + * + * @param token Loggly customer token + * @param restApi + * implementation of {@link ILogglyRestService} + */ + LogglyClient(String token, ILogglyRestService restApi) { + this.token = token; + this.loggly = restApi; + } + + /** + * Sets the tags to use for Loggly messages. The list of strings are + * converted into a single CSV (trailing/leading spaces stripped from each + * entry). + * @param tags + * CSV or list of tags + */ + public void setTags(String...tags) { + StringBuilder builder = new StringBuilder(); + boolean first = true; + for (String s: tags) { + for (String t: s.split(",")) { + t = t.trim(); + if (!t.isEmpty()) { + if (!first) { + builder.append(","); + } + builder.append(t); + } + first = false; + } + } + // "tags" field must be null for Retrofit to exclude Loggly tags header. + // Empty header string is not acceptable. + this.tags = builder.length() > 0 ? builder.toString() : null; + } + + /** + * Posts a log message to Loggly + * @param message message to be logged + * @return {@code true} if successful; {@code false} otherwise + */ + public boolean log(String message) { + if (message == null) return false; + + boolean ok; + try { + ok = loggly.log(token, tags, new TypedString(message)).isOk(); + } catch (Exception e) { + e.printStackTrace(); + ok = false; + } + return ok; + } + + /** + * Posts a log message asynchronously to Loggly + * @param message + * message to be logged + * @param callback + * callback to be invoked on completion of the post + */ + + public void log(String message, final Callback callback) { + if (message == null) return; + + loggly.log(token, tags, new TypedString(message), + new retrofit.Callback < LogglyResponse > () { + public void success(LogglyResponse logglyResponse, + Response response) { + callback.success(); + } + + public void failure(RetrofitError retrofitError) { + callback.failure(retrofitError.getMessage()); + } + }); + } + + /** + * Posts several log messages in bulk to Loggly + * @param messages + * messages to be logged + * @return {@code true} if successful; {@code false} otherwise + */ + public boolean logBulk(String...messages) { + if (messages == null) return false; + return logBulk(Arrays.asList(messages)); + } + + /** + * Posts several log messages in bulk to Loggly + * @param messages + * messages to be logged + * @return {@code true} if successful; {@code false} otherwise + */ + public boolean logBulk(Collection < String > messages) { + if (messages == null) return false; + + String parcel = joinStrings(messages); + if (parcel.isEmpty()) return false; + + boolean ok; + try { + ok = loggly.logBulk(token, tags, new TypedString(parcel)).isOk(); + } catch (Exception e) { + e.printStackTrace(); + ok = false; + } + return ok; + } + + /** + * Posts several log messages in bulk to Loggly asynchronously + * @param messages + * messages to be logged + * @param callback + * callback to be invoked on completion of the post + */ + public void logBulk(Collection < String > messages, final Callback callback) { + if (messages == null) return; + + String parcel = joinStrings(messages); + if (parcel.isEmpty()) return; + + loggly.logBulk(token, tags, new TypedString(parcel), + new retrofit.Callback < LogglyResponse > () { + public void success(LogglyResponse logglyResponse, + Response response) { + callback.success(); + } + + public void failure(RetrofitError retrofitError) { + callback.failure(retrofitError.getMessage()); + } + }); + } + + /** + * Combines a collection of messages to be sent to Loggly. In order to + * preserve event boundaries, the new lines in each message are replaced + * with '\r', which get stripped by Loggly. + * @param messages + * messages to be combined + * @return a single string containing all the messages + */ + private String joinStrings(Collection < String > messages) { + StringBuilder b = new StringBuilder(); + for (String s: messages) { + if (s == null || s.isEmpty()) { + continue; + } + + // Preserve new-lines in this event by replacing them + // with "\r". Otherwise, they're processed as event + // delimiters, resulting in unintentional multiple events. + b.append(s.replaceAll("[\r\n]", "\r")).append('\n'); + } + return b.toString(); + } } From d09519e342ea8e1675b9a7875f7886b6ce7ea187 Mon Sep 17 00:00:00 2001 From: psquickitjayant Date: Tue, 11 Aug 2015 12:53:10 +0530 Subject: [PATCH 2/7] Restored Whitespaces --- src/main/java/com/github/tony19/loggly/LogglyClient.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/github/tony19/loggly/LogglyClient.java b/src/main/java/com/github/tony19/loggly/LogglyClient.java index d7cac41..bef7467 100644 --- a/src/main/java/com/github/tony19/loggly/LogglyClient.java +++ b/src/main/java/com/github/tony19/loggly/LogglyClient.java @@ -69,7 +69,6 @@ public LogglyClient(String token, String tag) { /** * Creates a Loggly client with the specified REST API. This is package * private for internal testing only. - * * @param token Loggly customer token * @param restApi * implementation of {@link ILogglyRestService} From 53708c8efc9858eb489c3d743d58287c0cac5012 Mon Sep 17 00:00:00 2001 From: psquickitjayant Date: Tue, 11 Aug 2015 14:30:57 +0530 Subject: [PATCH 3/7] Restored Whitespaces --- .../github/tony19/loggly/LogglyClient.java | 394 +++++++++--------- 1 file changed, 197 insertions(+), 197 deletions(-) diff --git a/src/main/java/com/github/tony19/loggly/LogglyClient.java b/src/main/java/com/github/tony19/loggly/LogglyClient.java index bef7467..2cd6126 100644 --- a/src/main/java/com/github/tony19/loggly/LogglyClient.java +++ b/src/main/java/com/github/tony19/loggly/LogglyClient.java @@ -31,201 +31,201 @@ * @author tony19@gmail.com */ public class LogglyClient implements ILogglyClient { - private static final String API_URL = "http://logs-01.loggly.com/"; - private ILogglyRestService loggly; - private String token; - static String tags = "android"; - - /** - * Creates a Loggly client - * @param token Loggly customer token - * http://loggly.com/docs/customer-token-authentication-token/tag/android - */ - public LogglyClient(String token) { - this(token, tags); - if (token == null || token.isEmpty()) { - throw new IllegalArgumentException("token cannot be empty"); - } - - RestAdapter restAdapter = new RestAdapter.Builder() - .setEndpoint(API_URL).build(); - - this.token = token; - this.loggly = restAdapter.create(ILogglyRestService.class); - } - - public LogglyClient(String token, String tag) { - if (token == null || token.isEmpty()) { - throw new IllegalArgumentException("token cannot be empty"); - } - - RestAdapter restAdapter = new RestAdapter.Builder() - .setEndpoint(API_URL).build(); - this.tags = tag; - this.token = token; - this.loggly = restAdapter.create(ILogglyRestService.class); - } - - /** - * Creates a Loggly client with the specified REST API. This is package - * private for internal testing only. - * @param token Loggly customer token - * @param restApi - * implementation of {@link ILogglyRestService} - */ - LogglyClient(String token, ILogglyRestService restApi) { - this.token = token; - this.loggly = restApi; - } - - /** - * Sets the tags to use for Loggly messages. The list of strings are - * converted into a single CSV (trailing/leading spaces stripped from each - * entry). - * @param tags - * CSV or list of tags - */ - public void setTags(String...tags) { - StringBuilder builder = new StringBuilder(); - boolean first = true; - for (String s: tags) { - for (String t: s.split(",")) { - t = t.trim(); - if (!t.isEmpty()) { - if (!first) { - builder.append(","); - } - builder.append(t); - } - first = false; - } - } - // "tags" field must be null for Retrofit to exclude Loggly tags header. - // Empty header string is not acceptable. - this.tags = builder.length() > 0 ? builder.toString() : null; - } - - /** - * Posts a log message to Loggly - * @param message message to be logged - * @return {@code true} if successful; {@code false} otherwise - */ - public boolean log(String message) { - if (message == null) return false; - - boolean ok; - try { - ok = loggly.log(token, tags, new TypedString(message)).isOk(); - } catch (Exception e) { - e.printStackTrace(); - ok = false; - } - return ok; - } - - /** - * Posts a log message asynchronously to Loggly - * @param message - * message to be logged - * @param callback - * callback to be invoked on completion of the post - */ - - public void log(String message, final Callback callback) { - if (message == null) return; - - loggly.log(token, tags, new TypedString(message), - new retrofit.Callback < LogglyResponse > () { - public void success(LogglyResponse logglyResponse, - Response response) { - callback.success(); - } - - public void failure(RetrofitError retrofitError) { - callback.failure(retrofitError.getMessage()); - } - }); - } - - /** - * Posts several log messages in bulk to Loggly - * @param messages - * messages to be logged - * @return {@code true} if successful; {@code false} otherwise - */ - public boolean logBulk(String...messages) { - if (messages == null) return false; - return logBulk(Arrays.asList(messages)); - } - - /** - * Posts several log messages in bulk to Loggly - * @param messages - * messages to be logged - * @return {@code true} if successful; {@code false} otherwise - */ - public boolean logBulk(Collection < String > messages) { - if (messages == null) return false; - - String parcel = joinStrings(messages); - if (parcel.isEmpty()) return false; - - boolean ok; - try { - ok = loggly.logBulk(token, tags, new TypedString(parcel)).isOk(); - } catch (Exception e) { - e.printStackTrace(); - ok = false; - } - return ok; - } - - /** - * Posts several log messages in bulk to Loggly asynchronously - * @param messages - * messages to be logged - * @param callback - * callback to be invoked on completion of the post - */ - public void logBulk(Collection < String > messages, final Callback callback) { - if (messages == null) return; - - String parcel = joinStrings(messages); - if (parcel.isEmpty()) return; - - loggly.logBulk(token, tags, new TypedString(parcel), - new retrofit.Callback < LogglyResponse > () { - public void success(LogglyResponse logglyResponse, - Response response) { - callback.success(); - } - - public void failure(RetrofitError retrofitError) { - callback.failure(retrofitError.getMessage()); - } - }); - } - - /** - * Combines a collection of messages to be sent to Loggly. In order to - * preserve event boundaries, the new lines in each message are replaced - * with '\r', which get stripped by Loggly. - * @param messages - * messages to be combined - * @return a single string containing all the messages - */ - private String joinStrings(Collection < String > messages) { - StringBuilder b = new StringBuilder(); - for (String s: messages) { - if (s == null || s.isEmpty()) { - continue; - } - - // Preserve new-lines in this event by replacing them - // with "\r". Otherwise, they're processed as event - // delimiters, resulting in unintentional multiple events. - b.append(s.replaceAll("[\r\n]", "\r")).append('\n'); - } - return b.toString(); - } + private static final String API_URL = "http://logs-01.loggly.com/"; + private ILogglyRestService loggly; + private String token; + static String tags = "android"; + + /** + * Creates a Loggly client + * @param token Loggly customer token + * http://loggly.com/docs/customer-token-authentication-token/tag/android + */ + public LogglyClient(String token) { + this(token, tags); + if (token == null || token.isEmpty()) { + throw new IllegalArgumentException("token cannot be empty"); + } + + RestAdapter restAdapter = new RestAdapter.Builder() + .setEndpoint(API_URL).build(); + + this.token = token; + this.loggly = restAdapter.create(ILogglyRestService.class); + } + + public LogglyClient(String token, String tag) { + if (token == null || token.isEmpty()) { + throw new IllegalArgumentException("token cannot be empty"); + } + + RestAdapter restAdapter = new RestAdapter.Builder() + .setEndpoint(API_URL).build(); + this.tags = tag; + this.token = token; + this.loggly = restAdapter.create(ILogglyRestService.class); + } + + /** + * Creates a Loggly client with the specified REST API. This is package + * private for internal testing only. + * @param token Loggly customer token + * @param restApi + * implementation of {@link ILogglyRestService} + */ + LogglyClient(String token, ILogglyRestService restApi) { + this.token = token; + this.loggly = restApi; + } + + /** + * Sets the tags to use for Loggly messages. The list of strings are + * converted into a single CSV (trailing/leading spaces stripped from each + * entry). + * @param tags + * CSV or list of tags + */ + public void setTags(String...tags) { + StringBuilder builder = new StringBuilder(); + boolean first = true; + for (String s: tags) { + for (String t: s.split(",")) { + t = t.trim(); + if (!t.isEmpty()) { + if (!first) { + builder.append(","); + } + builder.append(t); + } + first = false; + } + } + // "tags" field must be null for Retrofit to exclude Loggly tags header. + // Empty header string is not acceptable. + this.tags = builder.length() > 0 ? builder.toString() : null; + } + + /** + * Posts a log message to Loggly + * @param message message to be logged + * @return {@code true} if successful; {@code false} otherwise + */ + public boolean log(String message) { + if (message == null) return false; + + boolean ok; + try { + ok = loggly.log(token, tags, new TypedString(message)).isOk(); + } catch (Exception e) { + e.printStackTrace(); + ok = false; + } + return ok; + } + + /** + * Posts a log message asynchronously to Loggly + * @param message + * message to be logged + * @param callback + * callback to be invoked on completion of the post + */ + + public void log(String message, final Callback callback) { + if (message == null) return; + + loggly.log(token, tags, new TypedString(message), + new retrofit.Callback < LogglyResponse > () { + public void success(LogglyResponse logglyResponse, + Response response) { + callback.success(); + } + + public void failure(RetrofitError retrofitError) { + callback.failure(retrofitError.getMessage()); + } + }); + } + + /** + * Posts several log messages in bulk to Loggly + * @param messages + * messages to be logged + * @return {@code true} if successful; {@code false} otherwise + */ + public boolean logBulk(String...messages) { + if (messages == null) return false; + return logBulk(Arrays.asList(messages)); + } + + /** + * Posts several log messages in bulk to Loggly + * @param messages + * messages to be logged + * @return {@code true} if successful; {@code false} otherwise + */ + public boolean logBulk(Collection < String > messages) { + if (messages == null) return false; + + String parcel = joinStrings(messages); + if (parcel.isEmpty()) return false; + + boolean ok; + try { + ok = loggly.logBulk(token, tags, new TypedString(parcel)).isOk(); + } catch (Exception e) { + e.printStackTrace(); + ok = false; + } + return ok; + } + + /** + * Posts several log messages in bulk to Loggly asynchronously + * @param messages + * messages to be logged + * @param callback + * callback to be invoked on completion of the post + */ + public void logBulk(Collection < String > messages, final Callback callback) { + if (messages == null) return; + + String parcel = joinStrings(messages); + if (parcel.isEmpty()) return; + + loggly.logBulk(token, tags, new TypedString(parcel), + new retrofit.Callback < LogglyResponse > () { + public void success(LogglyResponse logglyResponse, + Response response) { + callback.success(); + } + + public void failure(RetrofitError retrofitError) { + callback.failure(retrofitError.getMessage()); + } + }); + } + + /** + * Combines a collection of messages to be sent to Loggly. In order to + * preserve event boundaries, the new lines in each message are replaced + * with '\r', which get stripped by Loggly. + * @param messages + * messages to be combined + * @return a single string containing all the messages + */ + private String joinStrings(Collection < String > messages) { + StringBuilder b = new StringBuilder(); + for (String s: messages) { + if (s == null || s.isEmpty()) { + continue; + } + + // Preserve new-lines in this event by replacing them + // with "\r". Otherwise, they're processed as event + // delimiters, resulting in unintentional multiple events. + b.append(s.replaceAll("[\r\n]", "\r")).append('\n'); + } + return b.toString(); + } } From b70fa9d80935d34ca021c58b7f4c380f8a40a85c Mon Sep 17 00:00:00 2001 From: psquickitjayant Date: Wed, 12 Aug 2015 17:38:48 +0530 Subject: [PATCH 4/7] Fixed Whitespace issues --- .../github/tony19/loggly/LogglyClient.java | 111 +++++++++--------- 1 file changed, 54 insertions(+), 57 deletions(-) diff --git a/src/main/java/com/github/tony19/loggly/LogglyClient.java b/src/main/java/com/github/tony19/loggly/LogglyClient.java index 2cd6126..0b5b812 100644 --- a/src/main/java/com/github/tony19/loggly/LogglyClient.java +++ b/src/main/java/com/github/tony19/loggly/LogglyClient.java @@ -34,12 +34,12 @@ private static final String API_URL = "http://logs-01.loggly.com/"; private ILogglyRestService loggly; private String token; - static String tags = "android"; + private static String tags = "android"; /** * Creates a Loggly client * @param token Loggly customer token - * http://loggly.com/docs/customer-token-authentication-token/tag/android + * http://loggly.com/docs/customer-token-authentication-token/tag/android */ public LogglyClient(String token) { this(token, tags); @@ -67,8 +67,8 @@ public LogglyClient(String token, String tag) { } /** - * Creates a Loggly client with the specified REST API. This is package - * private for internal testing only. + * Creates a Loggly client with the specified REST API. + * This is package private for internal testing only. * @param token Loggly customer token * @param restApi * implementation of {@link ILogglyRestService} @@ -79,25 +79,24 @@ public LogglyClient(String token, String tag) { } /** - * Sets the tags to use for Loggly messages. The list of strings are - * converted into a single CSV (trailing/leading spaces stripped from each - * entry). - * @param tags - * CSV or list of tags + * Sets the tags to use for Loggly messages. The list of + * strings are converted into a single CSV (trailing/leading + * spaces stripped from each entry). + * @param tags CSV or list of tags */ - public void setTags(String...tags) { + public void setTags(String... tags) { StringBuilder builder = new StringBuilder(); boolean first = true; - for (String s: tags) { - for (String t: s.split(",")) { - t = t.trim(); - if (!t.isEmpty()) { - if (!first) { - builder.append(","); - } - builder.append(t); - } - first = false; + for (String s : tags) { + for (String t : s.split(",")) { + t = t.trim(); + if (!t.isEmpty()) { + if (!first) { + builder.append(","); + } + builder.append(t); + } + first = false; } } // "tags" field must be null for Retrofit to exclude Loggly tags header. @@ -125,8 +124,7 @@ public boolean log(String message) { /** * Posts a log message asynchronously to Loggly - * @param message - * message to be logged + * @param message message to be logged * @param callback * callback to be invoked on completion of the post */ @@ -134,37 +132,36 @@ public boolean log(String message) { public void log(String message, final Callback callback) { if (message == null) return; - loggly.log(token, tags, new TypedString(message), - new retrofit.Callback < LogglyResponse > () { - public void success(LogglyResponse logglyResponse, - Response response) { - callback.success(); - } + loggly.log(token, + tags, + new TypedString(message), + new retrofit.Callback < LogglyResponse > () { + public void success(LogglyResponse logglyResponse, Response response) { + callback.success(); + } - public void failure(RetrofitError retrofitError) { - callback.failure(retrofitError.getMessage()); + public void failure(RetrofitError retrofitError) { + callback.failure(retrofitError.getMessage()); + } + }); } - }); - } /** * Posts several log messages in bulk to Loggly - * @param messages - * messages to be logged + * @param messages messages to be logged * @return {@code true} if successful; {@code false} otherwise */ - public boolean logBulk(String...messages) { + public boolean logBulk(String... messages) { if (messages == null) return false; return logBulk(Arrays.asList(messages)); } /** * Posts several log messages in bulk to Loggly - * @param messages - * messages to be logged + * @param messages messages to be logged * @return {@code true} if successful; {@code false} otherwise */ - public boolean logBulk(Collection < String > messages) { + public boolean logBulk(Collection messages) { if (messages == null) return false; String parcel = joinStrings(messages); @@ -182,41 +179,41 @@ public boolean logBulk(Collection < String > messages) { /** * Posts several log messages in bulk to Loggly asynchronously - * @param messages - * messages to be logged - * @param callback - * callback to be invoked on completion of the post + * @param messages messages to be logged + * @param callback callback to be invoked on completion of the post */ - public void logBulk(Collection < String > messages, final Callback callback) { + public void logBulk(Collection messages, final Callback callback) { if (messages == null) return; String parcel = joinStrings(messages); if (parcel.isEmpty()) return; - loggly.logBulk(token, tags, new TypedString(parcel), - new retrofit.Callback < LogglyResponse > () { - public void success(LogglyResponse logglyResponse, + loggly.logBulk(token, + tags, + new TypedString(parcel), + new retrofit.Callback < LogglyResponse > () { + public void success(LogglyResponse logglyResponse, Response response) { callback.success(); } - public void failure(RetrofitError retrofitError) { - callback.failure(retrofitError.getMessage()); + public void failure(RetrofitError retrofitError) { + callback.failure(retrofitError.getMessage()); + } + }); } - }); - } /** - * Combines a collection of messages to be sent to Loggly. In order to - * preserve event boundaries, the new lines in each message are replaced - * with '\r', which get stripped by Loggly. - * @param messages - * messages to be combined + * Combines a collection of messages to be sent to Loggly. + * In order to preserve event boundaries, the new lines in + * each message are replaced with '\r', which get stripped + * by Loggly. + * @param messages messages to be combined * @return a single string containing all the messages */ - private String joinStrings(Collection < String > messages) { + private String joinStrings(Collection messages) { StringBuilder b = new StringBuilder(); - for (String s: messages) { + for (String s : messages) { if (s == null || s.isEmpty()) { continue; } From 6280cbfcd0e0b854249ed27f1b76c407ecf52f56 Mon Sep 17 00:00:00 2001 From: psquickitjayant Date: Wed, 12 Aug 2015 17:48:12 +0530 Subject: [PATCH 5/7] Fixed Whitespace issues --- .../java/com/github/tony19/loggly/LogglyClient.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/github/tony19/loggly/LogglyClient.java b/src/main/java/com/github/tony19/loggly/LogglyClient.java index 0b5b812..d24909e 100644 --- a/src/main/java/com/github/tony19/loggly/LogglyClient.java +++ b/src/main/java/com/github/tony19/loggly/LogglyClient.java @@ -135,7 +135,7 @@ public void log(String message, final Callback callback) { loggly.log(token, tags, new TypedString(message), - new retrofit.Callback < LogglyResponse > () { + new retrofit.Callback () { public void success(LogglyResponse logglyResponse, Response response) { callback.success(); } @@ -144,7 +144,7 @@ public void failure(RetrofitError retrofitError) { callback.failure(retrofitError.getMessage()); } }); - } + } /** * Posts several log messages in bulk to Loggly @@ -191,9 +191,8 @@ public void logBulk(Collection messages, final Callback callback) { loggly.logBulk(token, tags, new TypedString(parcel), - new retrofit.Callback < LogglyResponse > () { - public void success(LogglyResponse logglyResponse, - Response response) { + new retrofit.Callback () { + public void success(LogglyResponse logglyResponse,Response response) { callback.success(); } @@ -201,11 +200,11 @@ public void failure(RetrofitError retrofitError) { callback.failure(retrofitError.getMessage()); } }); - } + } /** * Combines a collection of messages to be sent to Loggly. - * In order to preserve event boundaries, the new lines in + * In order to preserve event boundaries, the new lines in * each message are replaced with '\r', which get stripped * by Loggly. * @param messages messages to be combined From c6cd0cace37eb4d1ace851fac4fb23d79257cc79 Mon Sep 17 00:00:00 2001 From: psquickitjayant Date: Wed, 12 Aug 2015 17:51:12 +0530 Subject: [PATCH 6/7] Fixed Whitespace issues --- .../github/tony19/loggly/LogglyClient.java | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/github/tony19/loggly/LogglyClient.java b/src/main/java/com/github/tony19/loggly/LogglyClient.java index d24909e..f5a6e51 100644 --- a/src/main/java/com/github/tony19/loggly/LogglyClient.java +++ b/src/main/java/com/github/tony19/loggly/LogglyClient.java @@ -27,7 +27,6 @@ /** * Loggly client - * * @author tony19@gmail.com */ public class LogglyClient implements ILogglyClient { @@ -48,7 +47,8 @@ public LogglyClient(String token) { } RestAdapter restAdapter = new RestAdapter.Builder() - .setEndpoint(API_URL).build(); + .setEndpoint(API_URL) + .build(); this.token = token; this.loggly = restAdapter.create(ILogglyRestService.class); @@ -67,11 +67,10 @@ public LogglyClient(String token, String tag) { } /** - * Creates a Loggly client with the specified REST API. + * Creates a Loggly client with the specified REST API. * This is package private for internal testing only. * @param token Loggly customer token - * @param restApi - * implementation of {@link ILogglyRestService} + * @param restApi implementation of {@link ILogglyRestService} */ LogglyClient(String token, ILogglyRestService restApi) { this.token = token; @@ -79,8 +78,8 @@ public LogglyClient(String token, String tag) { } /** - * Sets the tags to use for Loggly messages. The list of - * strings are converted into a single CSV (trailing/leading + * Sets the tags to use for Loggly messages. The list of + * strings are converted into a single CSV (trailing/leading * spaces stripped from each entry). * @param tags CSV or list of tags */ @@ -125,8 +124,7 @@ public boolean log(String message) { /** * Posts a log message asynchronously to Loggly * @param message message to be logged - * @param callback - * callback to be invoked on completion of the post + * @param callback callback to be invoked on completion of the post */ public void log(String message, final Callback callback) { @@ -135,7 +133,7 @@ public void log(String message, final Callback callback) { loggly.log(token, tags, new TypedString(message), - new retrofit.Callback () { + new retrofit.Callback() { public void success(LogglyResponse logglyResponse, Response response) { callback.success(); } @@ -191,10 +189,10 @@ public void logBulk(Collection messages, final Callback callback) { loggly.logBulk(token, tags, new TypedString(parcel), - new retrofit.Callback () { + new retrofit.Callback() { public void success(LogglyResponse logglyResponse,Response response) { - callback.success(); - } + callback.success(); + } public void failure(RetrofitError retrofitError) { callback.failure(retrofitError.getMessage()); From e352d09085a5609cc543f263fb947fb413b4af6c Mon Sep 17 00:00:00 2001 From: psquickitjayant Date: Wed, 12 Aug 2015 17:53:29 +0530 Subject: [PATCH 7/7] Fixed Whitespace issues --- src/main/java/com/github/tony19/loggly/LogglyClient.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/github/tony19/loggly/LogglyClient.java b/src/main/java/com/github/tony19/loggly/LogglyClient.java index f5a6e51..49c4a77 100644 --- a/src/main/java/com/github/tony19/loggly/LogglyClient.java +++ b/src/main/java/com/github/tony19/loggly/LogglyClient.java @@ -27,6 +27,7 @@ /** * Loggly client + * * @author tony19@gmail.com */ public class LogglyClient implements ILogglyClient { @@ -47,8 +48,8 @@ public LogglyClient(String token) { } RestAdapter restAdapter = new RestAdapter.Builder() - .setEndpoint(API_URL) - .build(); + .setEndpoint(API_URL) + .build(); this.token = token; this.loggly = restAdapter.create(ILogglyRestService.class); @@ -190,7 +191,7 @@ public void logBulk(Collection messages, final Callback callback) { tags, new TypedString(parcel), new retrofit.Callback() { - public void success(LogglyResponse logglyResponse,Response response) { + public void success(LogglyResponse logglyResponse, Response response) { callback.success(); }