/Logan

Logan is a lightweight case logging system based on mobile platform.

Primary LanguageCMIT LicenseMIT

Logan

license Release Version PRs Welcome Platform Support

Logan is a lightweight case logging system based on mobile platform.

中文说明

Logan

Getting started

Android

Prerequisites

If you want to build the source, make sure your NDK version is not higher than 16.1.4479499.

Installation

Add the following content in the project build.gradle file:

compile 'com.dianping.android.sdk:logan:1.2.1'

Usage

You must init Logan before you use it. For example:

LoganConfig config = new LoganConfig.Builder()
        .setCachePath(getApplicationContext().getFilesDir().getAbsolutePath())
        .setPath(getApplicationContext().getExternalFilesDir(null).getAbsolutePath()
                + File.separator + "logan_v1")
        .setEncryptKey16("0123456789012345".getBytes())
        .setEncryptIV16("0123456789012345".getBytes())
        .build();
Logan.init(config);

After you init Logan, you can use Logan to write a log. Like this:

Logan.w("test logan", 1);

Logan.w method has two parameters:

  • String log: What you want to write;
  • int type: Log type. This is very important, best practices below content will show you how to using log type parameter.

If you want to write log to file immediately, you need to call flush function:

Logan.f();

If you want to see all of the log file information, you need to call getAllFilesInfo function:

Map<String, Long> map = Logan.getAllFilesInfo();
  • key: Log file date;
  • value: Log file size(Bytes).

Upload

Logan internal provides logging upload mechanism, in view of the need to upload the log to do the preprocessing. If you want to upload log file, you need to implement a SendLogRunnable:

public class RealSendLogRunnable extends SendLogRunnable {

    @Override
    public void sendLog(File logFile) {
      // logFile: After the pretreatment is going to upload the log file
      // Must Call finish after send log
      finish();
      if (logFile.getName().contains(".copy")) {
				logFile.delete();
			}
    }
}

NOTE: You must call finish method after send log. As written in the code above

Finally you need to call Logan.s method:

Logan.s(date, mSendLogRunnable);

One of the first parameter is date array(yyyy-MM-dd).

iOS & macOS

Installation

Logan supports CocoaPods methods for installing the library in a project.

Podfile

Import Logan in Xcode project, add Logan in podfile.

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'

target 'TargetName' do
pod 'Logan', '~> 1.2.1'
end

Then run the following command:

$ pod install

Logan Init

You must init Logan before you use it:

#import "Logan.h"

NSData *keydata = [@"0123456789012345" dataUsingEncoding:NSUTF8StringEncoding]; 
NSData *ivdata = [@"0123456789012345" dataUsingEncoding:NSUTF8StringEncoding];
uint64_t file_max = 10 * 1024 * 1024;
// logan init,incoming 16-bit key,16-bit iv,largest written to the file size(byte)
loganInit(keydata, ivdata, file_max);

#if DEBUG
loganUseASL(YES);
#endif

Usage

Write a log:

logan(1, @"this is a test");

Log parsing

java

Copy Logan/parser-java to your project.

Parsing log data

new LoganParser(Key16.getBytes(),Iv16.getBytes()).parse(InputStream, OutputStream)

node.js

Please refer to Example/Logan-Server/server.js.

Demo

How to use demo

Log protocol

Best Practices

Before Logan available, log report system is relatively scattered.

Before_Logan

To put it simply, the traditional idea is to piece together the problems that appear in the logs of each system, but the new idea is to aggregate and analyze all the logs generated by the user to find the scenes with problems.

The Logan core system consists of four modules:

  • Input
  • Storage
  • BackEnd
  • FrontEnd

Logan_Process

The new case analysis process is as follows:

Logan_Case

Article

A lightweight case logging system based on mobile platform developed by Meituan-Dianping — Logan

Logan: Open Source

Feature

In the future, we will provide a data platform based on Logan big data, including advanced functions such as machine learning, troubleshooting log solution, and big data feature analysis.

Finally, we hope to provide a more complete integrated case analysis ecosystem.

Logan_System

Module Open Source Processing Planning
iOS & macOS
Android
Web
Mini Programs
Back End
Front End

Contributing

For more information about contributing PRs and issues, see our Contribution Guidelines.

Authors

See also the list of contributors who participated in this project.

License

Logan is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments