loggly/loggly-client


A Java library for posting to Loggly https://www.loggly.com/docs/android-logs/

Download


Step 1. Add the JitPack repository to your build file

Add it in your root settings.gradle at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url 'https://jitpack.io' }
		}
	}

Add it in your settings.gradle.kts at the end of repositories:

	dependencyResolutionManagement {
		repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
		repositories {
			mavenCentral()
			maven { url = uri("https://jitpack.io") }
		}
	}

Add to pom.xml

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>

Add it in your build.sbt at the end of resolvers:

 
    resolvers += "jitpack" at "https://jitpack.io"
        
    

Add it in your project.clj at the end of repositories:

 
    :repositories [["jitpack" "https://jitpack.io"]]
        
    

Step 2. Add the dependency

	dependencies {
		implementation 'com.github.tony19:loggly-client:loggly-client-1.0.3'
	}
	dependencies {
		implementation("com.github.tony19:loggly-client:loggly-client-1.0.3")
	}
	<dependency>
	    <groupId>com.github.tony19</groupId>
	    <artifactId>loggly-client</artifactId>
	    <version>loggly-client-1.0.3</version>
	</dependency>

                            
    libraryDependencies += "com.github.tony19" % "loggly-client" % "loggly-client-1.0.3"
        
        

                            
    :dependencies [[com.github.tony19/loggly-client "loggly-client-1.0.3"]]
        
        

Readme


<h1>loggly-client <a href='https://tony19.ci.cloudbees.com/job/loggly-client/'><a href='https://tony19.ci.cloudbees.com/job/loggly-client/job/loggly-client-SNAPSHOT/'><img src='https://tony19.ci.cloudbees.com/buildStatus/icon?job=loggly-client/loggly-client-SNAPSHOT'></a></a></h1> <sup>v1.0.3</sup>

A Java library for posting log messages to Loggly, using Retrofit to interface with Loggly's REST API.

Quickstart

  1. Create a LogglyClient instance with your authorization token from Loggly.

    final String LOGGLY_TOKEN = /* your token */;
    final ILogglyClient loggly = new LogglyClient(LOGGLY_TOKEN);
    
  2. Log an event...

    loggly.log("Hello world!");
    

API

setTags(String... tags)

Sets the Loggly tag(s) with variable arity strings (or with a CSV) to be applied to all subsequent log calls. Specify empty string to clear all tags.

loggly.setTags("foo", "bar");
// or equivalently:
loggly.setTags("foo,bar");

log(String message)

Logs a single event

loggly.log("hello world!");

log(String message, Callback callback)

Logs an event asynchronously

loggly.log("hello",
        new LogglyClient.Callback() {
            @Override
            public void success() {
                System.out.println("ok");
            }

            @Override
            public void failure(String error) {
                System.err.println("error: " + error);
            }
        });

logBulk(String... messages)

Note: In order to preserve event boundaries in a bulk upload, loggly-client replaces new-line characters ('\n') with carriage-returns ('\r'), which are subsequently stripped by Loggly.

Logs multiple events in bulk with variable arity strings

loggly.logBulk("event 1", "event 2");

logBulk(Collection<String> messages)

Logs multiple events in bulk with a Collection<String>

Collection<String> events = Arrays.asList("event 1", "event 2");
loggly.logBulk(events);

logBulk(Collection<String> messages, Callback callback)

Logs multiple events asynchronously in bulk with a Collection<String>

Collection<String> events = Arrays.asList("event 1", "event 2");
loggly.logBulk(events,
        new LogglyClient.Callback() {
            @Override
            public void success() {
                System.out.println("ok");
            }

            @Override
            public void failure(String error) {
                System.err.println("error: " + error);
            }
        });

Download

loggly-client-1.0.3.jar

Gradle

compile 'com.github.tony19:loggly-client:1.0.3'

Maven

<dependency>
  <groupId>com.github.tony19</groupId>
  <artifactId>loggly-client</artifactId>
  <version>1.0.3</version>
</dependency>

Snapshots of the development version are available in Sonatype's snapshots repository.