Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flutter_boost_1.22.4
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
谢冠章
flutter_boost_1.22.4
Commits
bef1c5c8
Commit
bef1c5c8
authored
Mar 20, 2020
by
justin
Committed by
GitHub
Mar 20, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #627 from Firewayer/feature/Debuger_opt
Debugger增强优化
parents
19b1c101
4166c531
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
155 additions
and
15 deletions
+155
-15
android/src/main/java/com/idlefish/flutterboost/Debuger.java
android/src/main/java/com/idlefish/flutterboost/Debuger.java
+45
-15
android/src/main/java/com/idlefish/flutterboost/log/AndroidLog.java
...c/main/java/com/idlefish/flutterboost/log/AndroidLog.java
+66
-0
android/src/main/java/com/idlefish/flutterboost/log/ILog.java
...oid/src/main/java/com/idlefish/flutterboost/log/ILog.java
+44
-0
No files found.
android/src/main/java/com/idlefish/flutterboost/Debuger.java
View file @
bef1c5c8
/*
* The MIT License (MIT)
*
*
* Copyright (c) 2019 Alibaba Group
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
...
...
@@ -26,15 +26,21 @@ package com.idlefish.flutterboost;
import
android.util.Log
;
import
com.idlefish.flutterboost.log.AndroidLog
;
import
com.idlefish.flutterboost.log.ILog
;
public
class
Debuger
{
private
static
final
String
TAG
=
"FlutterBoost#"
;
private
static
final
Debuger
DEBUG
=
new
Debuger
();
private
static
boolean
sSafeMode
=
false
;
private
static
ILog
sLog
=
new
AndroidLog
();
private
Debuger
(){
}
private
Debuger
()
{
}
private
void
print
(
String
info
)
{
if
(
isDebug
())
{
Log
.
e
(
TAG
,
info
);
if
(
isDebug
())
{
s
Log
.
e
(
TAG
,
info
);
}
}
...
...
@@ -43,26 +49,50 @@ public class Debuger {
}
public
static
void
exception
(
String
message
)
{
if
(
isDebug
())
{
if
(
canThrowError
())
{
throw
new
RuntimeException
(
message
);
}
else
{
Log
.
e
(
TAG
,
"exception"
,
new
RuntimeException
(
message
));
}
else
{
sLog
.
e
(
TAG
,
"exception"
,
new
RuntimeException
(
message
));
}
}
public
static
void
exception
(
Throwable
t
)
{
if
(
isDebug
())
{
if
(
canThrowError
())
{
throw
new
RuntimeException
(
t
);
}
else
{
Log
.
e
(
TAG
,
"exception"
,
t
);
}
else
{
sLog
.
e
(
TAG
,
"exception"
,
t
);
}
}
public
static
boolean
isDebug
(){
public
static
boolean
isDebug
()
{
try
{
return
FlutterBoost
.
instance
().
platform
().
isDebug
();
}
catch
(
Throwable
t
)
{
}
catch
(
Throwable
t
)
{
return
false
;
}
}
/**
* 设置boost log接收实现,默认为Anroid自带Log
*
* @param log
*/
public
static
void
setLog
(
ILog
log
)
{
if
(
log
!=
null
)
{
sLog
=
log
;
}
}
/**
* 设置Debugger策略倾向,如tue,则优先保证程序稳定,false,可抛Error
*
* @param safeMode
*/
public
static
void
setSafeMode
(
boolean
safeMode
)
{
sSafeMode
=
safeMode
;
}
private
static
boolean
canThrowError
()
{
return
isDebug
()
&&
!
sSafeMode
;
}
}
android/src/main/java/com/idlefish/flutterboost/log/AndroidLog.java
0 → 100644
View file @
bef1c5c8
package
com.idlefish.flutterboost.log
;
import
android.util.Log
;
public
class
AndroidLog
implements
ILog
{
@Override
public
void
d
(
String
tag
,
String
msg
)
{
Log
.
d
(
tag
,
msg
);
}
@Override
public
void
d
(
String
tag
,
String
msg
,
Throwable
throwable
)
{
Log
.
d
(
tag
,
msg
,
throwable
);
}
@Override
public
void
e
(
String
tag
,
String
msg
)
{
Log
.
e
(
tag
,
msg
);
}
@Override
public
void
e
(
String
tag
,
String
msg
,
Throwable
throwable
)
{
Log
.
e
(
tag
,
msg
,
throwable
);
}
@Override
public
void
i
(
String
tag
,
String
msg
)
{
Log
.
i
(
tag
,
msg
);
}
@Override
public
void
i
(
String
tag
,
String
msg
,
Throwable
throwable
)
{
Log
.
i
(
tag
,
msg
,
throwable
);
}
@Override
public
void
v
(
String
tag
,
String
msg
)
{
Log
.
v
(
tag
,
msg
);
}
@Override
public
void
v
(
String
tag
,
String
msg
,
Throwable
throwable
)
{
Log
.
v
(
tag
,
msg
,
throwable
);
}
@Override
public
void
w
(
String
tag
,
String
msg
)
{
Log
.
w
(
tag
,
msg
);
}
@Override
public
void
w
(
String
tag
,
String
msg
,
Throwable
throwable
)
{
Log
.
w
(
tag
,
msg
,
throwable
);
}
@Override
public
boolean
isLogLevelEnabled
(
int
level
)
{
return
true
;
}
}
android/src/main/java/com/idlefish/flutterboost/log/ILog.java
0 → 100644
View file @
bef1c5c8
package
com.idlefish.flutterboost.log
;
public
interface
ILog
{
public
enum
LogLevelEnum
{
VERBOSE
(
0
,
"V"
),
DEBUG
(
1
,
"D"
),
INFO
(
2
,
"I"
),
WARNING
(
3
,
"W"
),
ERROR
(
4
,
"E"
);
private
String
logLevelName
;
private
int
loglevel
;
LogLevelEnum
(
int
loglevel
,
String
name
)
{
this
.
loglevel
=
loglevel
;
this
.
logLevelName
=
name
;
}
public
String
getLogLevelName
()
{
return
logLevelName
;
}
public
int
getLoglevel
()
{
return
loglevel
;
}
}
void
d
(
String
tag
,
String
msg
);
void
d
(
String
tag
,
String
msg
,
Throwable
throwable
);
void
e
(
String
tag
,
String
msg
);
void
e
(
String
tag
,
String
msg
,
Throwable
throwable
);
void
i
(
String
tag
,
String
msg
);
void
i
(
String
tag
,
String
msg
,
Throwable
throwable
);
void
v
(
String
tag
,
String
msg
);
void
v
(
String
tag
,
String
msg
,
Throwable
throwable
);
void
w
(
String
tag
,
String
msg
);
void
w
(
String
tag
,
String
msg
,
Throwable
throwable
);
boolean
isLogLevelEnabled
(
int
level
);
}
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