Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
YDL-Component-Medical
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨凯
YDL-Component-Medical
Commits
189d2e01
Commit
189d2e01
authored
Feb 07, 2020
by
yjiucheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
格式化代码
parent
4ec55a67
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
29 deletions
+31
-29
LogHelper.kt
ydl-platform/src/main/java/com/ydl/ydlcommon/utils/log/LogHelper.kt
+31
-29
No files found.
ydl-platform/src/main/java/com/ydl/ydlcommon/utils/log/LogHelper.kt
View file @
189d2e01
...
...
@@ -2,14 +2,13 @@ package com.ydl.ydlcommon.utils.log
import
android.content.Context
import
android.util.Log
import
com.yidianling.common.tools.*
import
com.ydl.ydlcommon.base.BaseApp
import
com.ydl.ydlcommon.data.PlatformDataManager
import
com.ydl.ydlcommon.data.http.LogParam
import
com.ydl.ydlcommon.data.http.ThrowableConsumer
import
com.ydl.ydlcommon.modular.ModularServiceManager
import
com.ydl.ydlcommon.utils.FileUtils
import
com.yidianling.common.tools.*
import
io.reactivex.Observable
import
io.reactivex.android.schedulers.AndroidSchedulers
import
io.reactivex.functions.Consumer
...
...
@@ -40,7 +39,7 @@ class LogHelper private constructor() {
}
catch
(
e
:
Exception
)
{
}
}.
subscribeOn
(
Schedulers
.
io
())
.
subscribe
()
.
subscribe
()
}
/**
...
...
@@ -73,7 +72,7 @@ class LogHelper private constructor() {
}
catch
(
e
:
Exception
)
{
}
}.
subscribeOn
(
Schedulers
.
io
())
.
subscribe
()
.
subscribe
()
}
private
fun
writeLog
(
content
:
String
,
className
:
String
,
methodName
:
String
,
line
:
Int
)
{
...
...
@@ -82,7 +81,7 @@ class LogHelper private constructor() {
val
writer
=
BufferedWriter
(
fileWriter
)
writer
.
write
(
"""Time:${format.format(Calendar.getInstance().time)}"""
)
writer
.
newLine
()
writer
.
write
(
"UserInfo:uid = ${
ModularServiceManager.getPlatformUserService()?.getUser()?.userId}"
)
writer
.
write
(
"UserInfo:uid = ${ModularServiceManager.getPlatformUserService()?.getUser()?.userId}"
)
writer
.
newLine
()
writer
.
write
(
"""Network:${RxNetTool.getNetWorkTypeName(BaseApp.getApp())}"""
)
writer
.
newLine
()
...
...
@@ -108,30 +107,32 @@ class LogHelper private constructor() {
}
fun
uploadLog
(
showToast
:
Boolean
)
{
fun
uploadLog
(
showToast
:
Boolean
)
{
Observable
.
create
<
File
>
{
it
.
onNext
(
zip
())
it
.
onComplete
()
}.
subscribeOn
(
Schedulers
.
io
())
.
flatMap
{
PlatformDataManager
.
getHttp
().
uploadLog
(
.
flatMap
{
PlatformDataManager
.
getHttp
().
uploadLog
(
LogParam
(
it
)
)
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
Consumer
{
if
(
showToast
){
ToastUtil
.
toastShort
(
it
.
msg
)
}
Log
.
d
(
"TAG"
,
""
)
},
object
:
ThrowableConsumer
()
{
override
fun
accept
(
msg
:
String
)
{
if
(
showToast
){
ToastUtil
.
toastShort
(
msg
)
}
Log
.
d
(
"TAG"
,
msg
)
)
}
.
observeOn
(
AndroidSchedulers
.
mainThread
())
.
subscribe
(
Consumer
{
if
(
showToast
)
{
ToastUtil
.
toastShort
(
it
.
msg
)
}
Log
.
d
(
"TAG"
,
""
)
},
object
:
ThrowableConsumer
()
{
override
fun
accept
(
msg
:
String
)
{
if
(
showToast
)
{
ToastUtil
.
toastShort
(
msg
)
}
})
Log
.
d
(
"TAG"
,
msg
)
}
})
}
...
...
@@ -153,18 +154,18 @@ class LogHelper private constructor() {
if
(
zipFile
.
exists
())
zipFile
.
delete
()
zipFile
.
createNewFile
()
if
(
appLog
.
exists
()){
if
(
appLog
.
exists
())
{
files
.
add
(
appLog
)
}
if
(
yunxinLog
.
exists
()){
if
(
yunxinLog
.
exists
())
{
files
.
add
(
yunxinLog
)
}
if
(
agoraLog
.
exists
()){
if
(
agoraLog
.
exists
())
{
files
.
add
(
agoraLog
)
}
// ZipUtils.toZip(getLogFolder().absolutePath, FileOutputStream(zipFile), true)
ZipUtils
.
toZip
(
files
,
FileOutputStream
(
zipFile
))
ZipUtils
.
toZip
(
files
,
FileOutputStream
(
zipFile
))
return
zipFile
}
...
...
@@ -213,14 +214,15 @@ class LogHelper private constructor() {
}
//获取云信日志路径
private
fun
getYunXinLog
(
context
:
Context
):
File
{
val
yunxin
=
FileUtils
.
getSDDirectory
()
+
"/"
+
context
.
packageName
+
"/nim/log"
private
fun
getYunXinLog
(
context
:
Context
):
File
{
val
yunxin
=
FileUtils
.
getSDDirectory
()
+
"/"
+
context
.
packageName
+
"/nim/log"
LogUtil
.
d
(
yunxin
)
return
File
(
yunxin
)
}
//获取声网日志
private
fun
getAgoraLog
(
context
:
Context
):
File
{
val
agora
=
FileUtils
.
getSDDirectory
()
+
"/"
+
context
.
packageName
+
"/agorasdk.log"
private
fun
getAgoraLog
(
context
:
Context
):
File
{
val
agora
=
FileUtils
.
getSDDirectory
()
+
"/"
+
context
.
packageName
+
"/agorasdk.log"
return
File
(
agora
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment