Skip to content

Commit

Permalink
Add support for custom tags
Browse files Browse the repository at this point in the history
  • Loading branch information
tony19 committed Mar 26, 2015
1 parent 294d16d commit 02ae590
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<dependency>
<groupId>com.github.tony19</groupId>
<artifactId>loggly-client</artifactId>
<version>1.0.2</version>
<version>1.0.3-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -81,7 +81,7 @@
<configuration>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<source>1.5</source>
<source>1.6</source>
<target>1.5</target>
</configuration>
</plugin>
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/com/github/tony19/timber/loggly/LogglyTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*
* @author tony19@gmail.com
*/
public class LogglyTree extends Timber.HollowTree {
public class LogglyTree extends Timber.HollowTree implements Timber.TaggedTree {

private final LogglyClient loggly;
private LogglyClient.Callback handler;
Expand Down Expand Up @@ -145,4 +145,16 @@ private String toJson(Level level, String message, Object... args) {
private void log(Level level, String message, Object... args) {
loggly.log(toJson(level, message, args), handler);
}

/**
* Sets the Loggly tag for all logs going forward. This differs from
* the API of {@code Timber.TaggedTree} in that it's not a one-shot
* tag.
* @param tag desired tag or CSV of multiple tags; use empty string
* to clear tags
*/
@Override
public final void tag(String tag) {
loggly.setTags(tag);
}
}

0 comments on commit 02ae590

Please sign in to comment.