Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
90114514
Commit
90114514
authored
Feb 21, 2014
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
LogBackend: use __android_log_print() on Android
parent
7757e59e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
65 additions
and
1 deletion
+65
-1
LogBackend.cxx
src/LogBackend.cxx
+35
-0
LogInit.cxx
src/LogInit.cxx
+30
-1
No files found.
src/LogBackend.cxx
View file @
90114514
...
...
@@ -36,6 +36,33 @@
#include <syslog.h>
#endif
#ifdef ANDROID
#include <android/log.h>
static
int
ToAndroidLogLevel
(
LogLevel
log_level
)
{
switch
(
log_level
)
{
case
LogLevel
:
:
DEBUG
:
return
ANDROID_LOG_DEBUG
;
case
LogLevel
:
:
INFO
:
case
LogLevel
:
:
DEFAULT
:
return
ANDROID_LOG_INFO
;
case
LogLevel
:
:
WARNING
:
return
ANDROID_LOG_WARN
;
case
LogLevel
:
:
ERROR
:
return
ANDROID_LOG_ERROR
;
}
assert
(
false
);
gcc_unreachable
();
}
#else
static
LogLevel
log_threshold
=
LogLevel
::
INFO
;
#ifdef HAVE_GLIB
...
...
@@ -176,9 +203,16 @@ FileLog(const Domain &domain, const char *message)
#endif
}
#endif
/* !ANDROID */
void
Log
(
const
Domain
&
domain
,
LogLevel
level
,
const
char
*
msg
)
{
#ifdef ANDROID
__android_log_print
(
ToAndroidLogLevel
(
level
),
"MPD"
,
"%s: %s"
,
domain
.
GetName
(),
msg
);
#else
if
(
level
<
log_threshold
)
return
;
...
...
@@ -190,4 +224,5 @@ Log(const Domain &domain, LogLevel level, const char *msg)
#endif
FileLog
(
domain
,
msg
);
#endif
/* !ANDROID */
}
src/LogInit.cxx
View file @
90114514
...
...
@@ -49,6 +49,8 @@
static
constexpr
Domain
log_domain
(
"log"
);
#ifndef ANDROID
static
int
out_fd
;
static
AllocatedPath
out_path
=
AllocatedPath
::
Null
();
...
...
@@ -101,16 +103,29 @@ parse_log_level(const char *value, unsigned line)
}
}
#endif
void
log_early_init
(
bool
verbose
)
{
#ifdef ANDROID
(
void
)
verbose
;
#else
if
(
verbose
)
SetLogThreshold
(
LogLevel
::
DEBUG
);
#endif
}
bool
log_init
(
bool
verbose
,
bool
use_stdout
,
Error
&
error
)
{
#ifdef ANDROID
(
void
)
verbose
;
(
void
)
use_stdout
;
(
void
)
error
;
return
true
;
#else
const
struct
config_param
*
param
;
#ifdef HAVE_GLIB
...
...
@@ -151,8 +166,11 @@ log_init(bool verbose, bool use_stdout, Error &error)
log_init_file
(
param
->
line
,
error
);
}
}
#endif
}
#ifndef ANDROID
static
void
close_log_files
(
void
)
{
...
...
@@ -161,16 +179,22 @@ close_log_files(void)
#endif
}
#endif
void
log_deinit
(
void
)
{
#ifndef ANDROID
close_log_files
();
out_path
=
AllocatedPath
::
Null
();
#endif
}
void
setup_log_output
(
bool
use_stdout
)
{
#ifdef ANDROID
(
void
)
use_stdout
;
#else
if
(
use_stdout
)
return
;
...
...
@@ -193,10 +217,14 @@ void setup_log_output(bool use_stdout)
#ifdef HAVE_GLIB
SetLogCharset
(
nullptr
);
#endif
#endif
}
int
cycle_log_files
(
void
)
{
#ifdef ANDROID
return
0
;
#else
int
fd
;
if
(
out_path
.
IsNull
())
...
...
@@ -217,4 +245,5 @@ int cycle_log_files(void)
redirect_logs
(
fd
);
FormatDebug
(
log_domain
,
"Done cycling log files"
);
return
0
;
#endif
}
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