• Stars
    star
    390
  • Rank 106,215 (Top 3 %)
  • Language
    Java
  • License
    Apache License 2.0
  • Created over 6 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Trojan is an efficient mobile terminal lightweight log SDK

Trojan is a stable and efficient mobile lightweight log SDK that not only records general logs, such as Http, power changes, component life cycles, but also records the definition of the log, which it is useful to analysis problems through the user logs. Here is the following characteristics:

  • Concise API, it is easy to achieve diary record function through a few lines of code;
  • Use the AOP technologies Lancet SDK, it is comfortable to collect common logs, also support incremental compile;
  • Use mmap technology to ensure the efficiency of log records;
  • Scalability, developers can customize the log file to achieve the purpose of the upload;
  • Small traffic overhead, remote control user log file upload or not by online configuration;
  • High stability, it is very stable at many apps.

中文介绍

Overview

In the open source Trojan SDK, we have collected basic logs such as Activity and Fragment lifecycles, View Click events, network status changes, phone battery status changes, also include collecting KLog logs, if KLog is not used in the project, it can be customized according to the project specific conditions. Considering that the implementation framework for network modules is different at fact, there are OkHttp, Volley, Android-Async-Http, etc. Therefore, this part of collecting network logs is not suitable for customization. Users can use Lancet to collect logs at the specific network framework. In Demo, we can achieve acquisition Http request and response functions in OkHttp, it can be used as a reference. As for business-related logs, users should collect by self.

Installation

Add in the root directory's build.gradle:

buildscript {
    dependencies {
        ......
        classpath 'me.ele:lancet-plugin:1.0.2'
    }
}

Add in the app directory's build.gradle:

apply plugin: 'me.ele.lancet'

dependencies {
    ......
    provided 'me.ele:lancet-base:1.0.2'
    compile 'me.ele:trojan-library:0.0.5'
}

Use

1. Initialization

Add in the custom Application:

TrojanConfig config = new TrojanConfig.Builder(this)
    // Set user information
    .userInfo("xxxx")
    // Set device id
    .deviceId("xxxx")
    // Set cipher key if need encry log
    .cipherKey("xxxx")
    // Optional, save log file in sdcard by default
    .logDir("xxxx")
    // Console log switch, the default is open
    .enableLog(true)
    .build();
Trojan.init(config);

Special Note:

  1. The log files are stored in sdcard by default and will not be lost even if the application is uninstalled;
  2. To be compatible with multiple processes, log files stored in their respective directories;
  3. The log is not encrypted by default, we currently only provide TEA encryption in view for high efficiency。

2. Record the log

Trojan provides two ways to recode log:

Firstly:

Trojan.log("Trojan", "We have a nice day!");

Secondly:

List<String> msgList = new LinkedList <>();
msgList.add("Hello Trojan!");
msgList.add("We have a nice day!");
msgList.add("Hello world!");
Trojan.log("Trojan", msgList);

By default, a single line log is not encrypted, and if you need to encrypt it, the following is used:

Trojan.log("Trojan", "We have a nice day!", true);

3. User Information

When the user information changes or switch users, you can call:

Trojan.refreshUser("new user info");

Of course, if the user logs out, you can pass a null value:

Trojan.refreshUser(null);

4. Upload Solution

In Demo we provided free and simple way such as LeanCloud to upload log file, you can browse, download and download log file.

5. Data Decryption

When we set the encryption key, we can encrypt a single log to ensure the security of sensitive data. We must decrypt the encrypted data When we analyze the log. Use the decryption script as follows:

  1. Compile and generate decryption SO library on MAC, The so library has been generated in the repository. This step can be omitted:

    gcc -shared -Wl,-install_name,trojan_decrypt.so -o trojan_decrypt.so -fPIC trojan_decrypt.c
  2. Call python script to decrypt the data on MAC, you need to pass in the decryption key and file path to be decrypted, it should be noted that the path of the python script:

    python ./trojan_decrypt.py cipher-key cipher-file-path

PS

Through the above steps, you can integrate Trojan SDK to record user's log, That is very simple! If you have any questions about the use of Lancet, you can get more details by Readme.

License

Trojan is available under the Apache-2.0 license. See the LICENSE file for more info.

More Repositories

1

UETool

Show/edit any view's attributions on the screen.
Java
3,256
star
2

lancet

A lightweight and fast AOP framework for Android App and SDK developers
Java
2,083
star
3

morjs

基于小程序 DSL(微信、支付宝)的,可扩展的多端研发框架,支持一键将微信或支付宝小程序转换为微信、支付宝、百度、字节、QQ、快手、淘宝、钉钉等小程序 或 Web 应用。
TypeScript
1,400
star
4

Amigo

A hotfix library for Android platform, and not just this...
Java
1,365
star
5

Stinger

Stinger is a high-efficiency library with great compatibility, for aop in Objective-C, using libffi instead of Objective-C message forwarding. It is 20+ times faster than the Aspects, from message-sending to Aspect-oriented code ends.
Objective-C
988
star
6

corvus

A fast and lightweight Redis Cluster Proxy for Redis 3.0
C
791
star
7

Mess

a gradle plugin for minifying activities, services, receivers, providers and custom view
Groovy
682
star
8

dna

dna, dart native access. A lightweight dart to native super channel plugin, You can use it to invoke any native code directly in contextual and chained dart code.
Dart
365
star
9

bigkeeper

Efficiency improvement for iOS&Android modular development.
Ruby
212
star
10

Intimate

Intimate 提供了友好的 API 让 java 反射的使用更加简单平滑。 其最核心的价值在于 Intimate 将在编译期对 apk 内部代码的调用进行反射优化,完全免除反射的效率问题,使得反射调用就像普通调用一样快捷且无任何代价。
Java
202
star
11

duang

自动 CMS 生成工具
JavaScript
199
star
12

tedis

基于TiKV的兼容Redis协议的强一致性NoSQL数据库
Go
181
star
13

eleme.github.io

Eleme Developers Homepage
CSS
116
star
14

Sparrow

Vue
79
star
15

mobilists

mobile team blog
JavaScript
57
star
16

thrift-parser

To parse thrift file to a AST.
JavaScript
53
star
17

meepo

Event sourcing and broadcasting for database.
Python
52
star
18

ruskit

Redis cluster administration toolkit
Python
34
star
19

doctor

Metric based in-memory circuit breaker for python
Python
23
star
20

react-context-global-store

A simple global store based on React context
TypeScript
22
star
21

NVMImageMaker

API for chaining image drawing codes in Objc.
Objective-C
19
star
22

node-thrift-protocol

An implementation of thrift-protocol with node.
JavaScript
18
star
23

easyxml

php xml lib
PHP
17
star
24

SparrowSDK-iOS

Objective-C
16
star
25

NVMAspects

C
15
star
26

thrift-php

Mirror of apache thrift php lib
PHP
10
star
27

thrift-client

A nodejs thrift client
JavaScript
8
star
28

python-jianfan-mirror

mirror of https://code.google.com/p/python-jianfan/
Python
4
star
29

SparrowSDK-Android

4
star
30

thrift-tracker

Go
1
star
31

finite

F-init-E
JavaScript
1
star
32

python-geohash-mirror

mirror of https://code.google.com/p/python-geohash/
Python
1
star