app log Tune-in and server interaction design
app log fetch interface design Interface Conventions
Interface Return Description
Parameters |
parameter Type |
Description |
Code |
Integer |
Meaning similar to the HTTP protocol return code, 200 means success |
Message |
String |
Returns the message, if code is an exception, the return message is exception information |
Data |
Object |
Data Objects, JSON objects |
failed Sample Data
{
code:500,
message: "The system is busy, please try again later",
data:{}
}
Notes
A user can upload multiple log files, and the background needs to consider how to store multiple log files for a user. Get app Log Configuration Interface
Interface Address
Http://api.dinghuo123.com/v2/applog/config.json
interface Method
GET
parameter Description
Parameters |
parameter Type |
whether you must |
Description |
Access_token |
String |
Is |
Access tokens |
Return Data Description
Parameters |
parameter Type |
Description |
Id |
Long |
Unique identity of the configuration |
Enableupload |
Boolean |
True for upload, false to not upload |
Networktype |
Integer |
Network type, 1 for wifi,2 represents 2g/3g/4g,3 for the collection of 1 and 2 (that is, any network type), which is effective when enableupload is true |
Networktypename |
String |
Network type name, easy to understand and debug, see Networktype and Networktypename correspondence table |
Scope |
Integer |
Upload range, when Enableupload is true, 1 for all, 2 for specified date |
StartDate |
String |
Start date, when the scope is 2 o'clock effective, the format is YYYY-MM-DD, |
EndDate |
String |
End date, when scope is 2 o'clock effective, the format is YYYY-MM-DD, not before StartDate, if StartDate is the same as the EndDate value, it means the log record of that day |
Networktype and Networktypename correspondence table
Networktype |
Networktypename |
1 |
Wifi |
2 |
2g/3g/4g |
3 |
All |
Successful Sample Data
{
code:200,
message: "Get app Log configured successfully",
data:{
id:1001,
enableupload:true,
networktype:1,
networktypename: "WIFI",
scope:2,
startdate: "2016-04-12",
endDate: "2016-04-13"
}
}
upload log file interface
Interface Address
Http://api.dinghuo123.com/v2/applog/upload.json
interface Method
POST
parameter Description
Parameters |
parameter Type |
whether you must |
Description |
Access_token |
String |
Is |
Access tokens |
File |
Binary |
Is |
Log file Binary stream |
Return Data Description
Parameters |
parameter Type |
Description |
FileName |
String |
File name, return this name, easy to debug the interface, convenient for technicians to find logs from the background |
Successful Sample Data
{
code:200,
message: "Upload log file succeeded",
data:{
fileName: "2016-04-13.log"
}
}
Update Log Configuration Interface
Interface Address
Http://api.dinghuo123.com/v2/applog/config_update.json
interface Method
POST
parameter Description
Parameters |
parameter Type |
whether you must |
Description |
Access_token |
String |
Is |
Access tokens |
Enableupload |
Boolean |
Is |
Whether to upload |
Return Data Description
Consistent with the data data structure returned by the Get app log configuration interface.
Successful Sample Data
{
code:200,
message: "Update log configuration Succeeded",
data:{
id:1001,
enableupload:false,
networktype : 1,
networktypename: "WIFI",
scope:2,
startdate: "2016-04-12",
endDate: "2016-04-13"
}
}
app operation Log Recording design
app upload log process design
Log Location
Log storage path:/SD root directory/ydh/log/user name/log file name. log
Meta Data |
definition |
SD Card root directory |
Android is the root directory of the SD card, iOS is the root directory of the app |
User name |
User's account name |
Log file name |
Date string in the format: YYYY-MM-DD. A log file corresponds to a user's use of the mobile app for a day. Upload the need to add a platform prefix before the file name, if it is an Android platform, add the prefix "Android_", if it is the IOS platform, add the prefix "Ios_" |
Example
User test2016 April 12 The action log file is:/mnt/ydh/log/test/2016-04-12.log log Content format user action log Content format
Meta Data |
definition |
Time |
Format is YYYY-MM-DD HH:MM:SS |
Module |
Commodity (product), order (order), User (user), authority (permission) |
Event |
Action events, with related definitions |
Log type |
Error (wrong), info (info) |
Event life cycle |
such as Start (start), End (ending) |
Error message |
If the type is error, you must bring the error message |
Order Events
Events |
definition |
Order Now |
Placeanorder |
User Events
Events |
definition |
Login |
Login |
Example
Start as: 2016-04-12 15:46:32 Order placeanorder INFO start
End success such as: 2016-04-12 15:46:32 Order placeanorder INFO End
End error such as: 2016-04-12 15:46:32 Order placeanorder error End {code:500,msg: "The system is busy, please try again later"} interface Call log Content format
Meta Data |
definition |
Time |
Format is YYYY-MM-DD HH:MM:SS |
Method |
POST, GET, PUT, DELETE |
Address |
Full URL with parameters on it |
Return code |
such as 200,404 |
Content Type |
HTTP header fields Content-type, such as application/x-www-form-urlencoded |
Input parameters |
When the method is post, the parameters are transmitted in body form |
return content |
The body-transmitted content returned by the interface call |
Example
Example: 2016-04-12 15:46:32 POST https://api.dinghuo123.com/oauth2/token application/x-www-form-urlencoded password= 654321&scope=basic&client_secret=3sfx3hjx484gxy&username=chase001&client_id=2124571&grant_ type=client_credentials {"Code": 525, "message": "The service the account belongs to has expired", "Data": "}
Typically an operation corresponds to multiple interface calls, so a complete example of an operation is:
2016-04-12 15:46:32 User Login INFO START
2016-04-12 15:46:33 POST Https://api.dinghuo123.com/oauth2/token application/x-www-form-urlencoded password= 654321&scope=basic&client_secret=3sfx3hjx484gxy&username=chase001&client_id=2124571&grant_ type=client_credentials {"Code": 525, "message": "The service the account belongs to has expired", "Data": "}
2016-04-12 15:46:37 User Login ERROR END {"Code": 525, "message": "The service to which the account belongs has expired", "Data": "}