Giter Club home page Giter Club logo

le_android's Introduction

Logging support for Android devices

License

Build requirements: Android SDK 2.3+ Runtime requirements: Android OS 2.3+

Features:

  • Send Logs via HTTP POST

    Option of changing from Token TCP to using HTTP POST sending to the endpoint 'https://js.logentries.com/v1/logs/LOG-TOKEN'

  • Send Logs via SSL

    The library can send logs via Token TCP over TLS/SSL over port 443 by default

  • Storing logs offline and sending when connected.

    While sending logs, if the device looses connection, logs are stored locally until a connection is reestablished then sent to Logentries. 10mb queue limit

  • TraceID

    Each log sent contains the device TraceID which is a unique 35 character ID.

Setup

Set up an account with Logentries at https://logentries.com/, and create a logfile, by clicking + Add New button and selecting the Manual Configuration Option at the bottom. Select Token TCP as the source type and copy the Token UUID printed in green.

Next, download the library jar file here and place it in the /yourProject/libs folder of your Android project.

Add the android.permission.INTERNET to the project manifest file.

Use

In the desired Activity class, import com.logentries.android.AndroidLogger

To create an instance of the Logger object in an Activity class: AndroidLogger logger = AndroidLogger.getLogger(Context context, boolean useHttpPost, boolean useSsl, boolean isUsingDataHub, String dataHubAddr, int dataHubPort, String token, boolean logHostName); Where

  • context: for example, if in an Activity class, use getApplicationContext(), or if in an Application class, use getBaseContext().

  • token: is the Token UUID we copied earlier which represents the logfile on Logentries

Log events are created using the following methods of the AndroidLogger class, which differ only in terms of the severity level they report:

  • severe, debug, info, config, fine, finer, finest, verbose

Eg: logger.error("Log Event Contents"); creates the log Sat Jul 30 16:04:36 GMT+00:00 2011, severity=ERROR, Log Event Contents.

Each method corresponds to those used in android.util.Log and java.util.logging.Logger.

DataHub Support

Additional constructors for AndroidLogger have been created for use with Logentries DataHub. There are two additional constructors added, one with a customID and one without customID. They are respectively:

  AndroidLogger logger = AndroidLogger.getLogger(Context context, String datahub_address, int datahub_port);

and

 AndroidLogger logger = AndroidLogger.getLogger(Context context, String datahub_address, int datahub_port, String customID);
  • context: for example, if in an Activity class, use getApplicationContext(), or if in an Application class, use getBaseContext().

  • datahub_address: is a String of the IP Address of your DataHub machine.

  • datahub_port: is an int of the port number of your incoming connection on your DataHub machine. The default is port 10000, but this can be changed to any port by altering the /etc/leproxy/leproxyLocal.config file on your DataHub machine and restarting the leproxy daemon using "sudo service leproxy restart".

  • customID - is a String of the customID you may wish to add to your log events. This is different from the deviceID which is now automatically set and entered into your logs.

The logger will now add the android deviceID as a Key Value Pair in your logs. This requires API 9 and above.

NOTE: You cannot use both Token-based and DataHub-based AndroidLogger constructors in your application. You can only use one or the other.

le_android's People

Contributors

c-fenlon avatar cheffernan-r7 avatar ericntd-legacy avatar hirro avatar m0wfo avatar marklc-r7 avatar michael-seibert-le avatar omgapuppy avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.