Intelligent hardware device logging service architecture

Log service functions are divided into two modules: logcat logs and logs buried point.

Log Type

definition

Feature

effect

logcat log

Each app to print the log Log

Full, but the key information is not obvious

Analysis of the current network for positioning problem

Buried log

Formatting log

Structured format / outstanding information / management platform can be used with statistics

1. Analysis of product operations for user data

2. Locate the current network problems

 

First, demand

logcat_reqirements

maidian_requirement

 

the whole frame

Overall framework

 

logcat log generation and uploading scene

logcat file generation and upload scene

Timing diagram

logcat log timing diagram

Buried log

Buried timing chart log

 

 

difficulty:

1. Log Process Management

Log Process Management

Instructions executed in the process: logcat -v time | egrep -i "abcd"

 

2. Blocking output log reads the log process

buffRead = new BufferedReader(new InputStreamReader(process.getInputStream()));
while ((line = buffRead.readLine()) != null) {
}

Here caching using StringBuffer, it is thread safe.

 

3. log output to a file and the encryption process

Read each line of the log will be spliced ​​into the cache, write to the file after a certain number.

It can also be a time of polling trigger write to a file. (There will be multi-threading issues)

Write files using: FileOutputStream

Compression and encryption: gZip using the first compression, and then performing an exclusive OR encryption, there is a certain risk of the secret key may be stored in the code.

 

4. logcat file upload

Since the individual files are small files, required to support HTTP, so simply put through an interface file request to the cloud.

 

5. Buried log storage and upload management

Buried sdk with a separate management.

Guess you like

Origin www.cnblogs.com/NeilZhang/p/10913747.html