Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
briar
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
675
Issues
675
List
Boards
Labels
Service Desk
Milestones
Merge Requests
11
Merge Requests
11
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
briar
briar
Commits
909e946e
Verified
Commit
909e946e
authored
Jul 01, 2019
by
akwizgran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable debug logging for debug and beta builds.
parent
408d9dde
Pipeline
#3653
passed with stage
in 9 minutes and 36 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
7 deletions
+48
-7
briar-android/src/main/java/org/briarproject/briar/android/BriarApplicationImpl.java
.../org/briarproject/briar/android/BriarApplicationImpl.java
+12
-7
briar-android/src/main/java/org/briarproject/briar/android/LevelRaisingHandler.java
...a/org/briarproject/briar/android/LevelRaisingHandler.java
+36
-0
No files found.
briar-android/src/main/java/org/briarproject/briar/android/BriarApplicationImpl.java
View file @
909e946e
...
...
@@ -37,6 +37,7 @@ import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREG
import
static
android
.
os
.
Build
.
VERSION
.
SDK_INT
;
import
static
java
.
util
.
logging
.
Level
.
FINE
;
import
static
java
.
util
.
logging
.
Level
.
INFO
;
import
static
java
.
util
.
logging
.
Logger
.
getLogger
;
import
static
org
.
acra
.
ReportField
.
ANDROID_VERSION
;
import
static
org
.
acra
.
ReportField
.
APP_VERSION_CODE
;
import
static
org
.
acra
.
ReportField
.
APP_VERSION_NAME
;
...
...
@@ -82,7 +83,7 @@ public class BriarApplicationImpl extends Application
implements
BriarApplication
{
private
static
final
Logger
LOG
=
Logger
.
getLogger
(
BriarApplicationImpl
.
class
.
getName
());
getLogger
(
BriarApplicationImpl
.
class
.
getName
());
private
final
CachingLogHandler
logHandler
=
new
CachingLogHandler
();
private
final
BackgroundMonitor
backgroundMonitor
=
new
BackgroundMonitor
();
...
...
@@ -108,12 +109,16 @@ public class BriarApplicationImpl extends Application
if
(
IS_DEBUG_BUILD
)
enableStrictMode
();
Logger
rootLogger
=
Logger
.
getLogger
(
""
);
if
(!
IS_DEBUG_BUILD
&&
!
IS_BETA_BUILD
)
{
// Remove default log handlers so system log is not used
for
(
Handler
handler
:
rootLogger
.
getHandlers
())
{
rootLogger
.
removeHandler
(
handler
);
}
Logger
rootLogger
=
getLogger
(
""
);
Handler
[]
handlers
=
rootLogger
.
getHandlers
();
// Disable the Android logger for release builds
for
(
Handler
handler
:
handlers
)
rootLogger
.
removeHandler
(
handler
);
if
(
IS_DEBUG_BUILD
||
IS_BETA_BUILD
)
{
// We can't set the level of the Android logger at runtime, so
// raise records to the logger's default level
rootLogger
.
addHandler
(
new
LevelRaisingHandler
(
FINE
,
INFO
));
// Restore the default handlers after the level raising handler
for
(
Handler
handler
:
handlers
)
rootLogger
.
addHandler
(
handler
);
}
rootLogger
.
addHandler
(
logHandler
);
rootLogger
.
setLevel
(
IS_DEBUG_BUILD
||
IS_BETA_BUILD
?
FINE
:
INFO
);
...
...
briar-android/src/main/java/org/briarproject/briar/android/LevelRaisingHandler.java
0 → 100644
View file @
909e946e
package
org.briarproject.briar.android
;
import
java.util.logging.Handler
;
import
java.util.logging.Level
;
import
java.util.logging.LogRecord
;
/**
* Log handler that raises all records at or above a given source level to a
* given destination level. This affects the level seen by subsequent handlers.
*/
class
LevelRaisingHandler
extends
Handler
{
private
final
Level
dest
;
private
final
int
srcInt
,
destInt
;
LevelRaisingHandler
(
Level
src
,
Level
dest
)
{
this
.
dest
=
dest
;
srcInt
=
src
.
intValue
();
destInt
=
dest
.
intValue
();
if
(
srcInt
>
destInt
)
throw
new
IllegalArgumentException
();
}
@Override
public
void
publish
(
LogRecord
record
)
{
int
recordInt
=
record
.
getLevel
().
intValue
();
if
(
recordInt
>=
srcInt
&&
recordInt
<
destInt
)
record
.
setLevel
(
dest
);
}
@Override
public
void
flush
()
{
}
@Override
public
void
close
()
{
}
}
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