Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
spdlog
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
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
spdlog
Commits
96267654
Commit
96267654
authored
Sep 14, 2016
by
Hugh Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Android examples.
parent
72a6fd65
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
3 deletions
+35
-3
.gitignore
.gitignore
+2
-1
example.cpp
example/example.cpp
+14
-2
Android.mk
example/jni/Android.mk
+15
-0
Application.mk
example/jni/Application.mk
+2
-0
example.cpp
example/jni/example.cpp
+2
-0
No files found.
.gitignore
View file @
96267654
# Auto generated files
# Auto generated files
*.slo
*.lo
*.o
...
...
@@ -46,6 +46,7 @@ example/*
!example/example.vcxproj
!example/CMakeLists.txt
!example/multisink.cpp
!example/jni
# generated files
generated
...
...
example/example.cpp
View file @
96267654
...
...
@@ -13,6 +13,7 @@
void
async_example
();
void
syslog_example
();
void
android_example
();
void
user_defined_example
();
void
err_handler_example
();
...
...
@@ -48,7 +49,6 @@ int main(int, char*[])
auto
my_logger
=
spd
::
basic_logger_mt
(
"basic_logger"
,
"logs/basic.txt"
);
my_logger
->
info
(
"Some log message"
);
// Create a file rotating logger with 5mb size max and 3 rotated files
auto
rotating_logger
=
spd
::
rotating_logger_mt
(
"some_logger_name"
,
"logs/mylogfile"
,
1048576
*
5
,
3
);
for
(
int
i
=
0
;
i
<
10
;
++
i
)
...
...
@@ -76,6 +76,9 @@ int main(int, char*[])
// syslog example. linux/osx only
syslog_example
();
// android example. compile with NDK
android_example
();
// Log user-defined types example
user_defined_example
();
...
...
@@ -119,6 +122,16 @@ void syslog_example()
#endif
}
// Android example
void
android_example
()
{
#if defined(__ANDROID__)
std
::
string
tag
=
"spdlog-android"
;
auto
android_logger
=
spd
::
android_logger
(
"android"
,
tag
);
android_logger
->
critical
(
"Use
\"
adb shell logcat
\"
to view this message."
);
#endif
}
// user defined types logging by implementing operator<<
struct
my_type
{
...
...
@@ -148,4 +161,3 @@ void err_handler_example()
});
spd
::
get
(
"console"
)
->
info
(
"some invalid message to trigger an error {}{}{}{}"
,
3
);
}
example/jni/Android.mk
0 → 100644
View file @
96267654
# Setup a project
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := example
LOCAL_SRC_FILES := example.cpp
LOCAL_CPPFLAGS += -Wall -Wshadow -Wextra -pedantic -std=c++11 -fPIE -pie
LOCAL_LDFLAGS += -fPIE -pie
# Add exception support and set path for spdlog's headers
LOCAL_CPPFLAGS += -fexceptions -I../include
# Use android's log library
LOCAL_LDFLAGS += -llog
include $(BUILD_EXECUTABLE)
example/jni/Application.mk
0 → 100644
View file @
96267654
# Exceptions are used in spdlog. Link to an exception-ready C++ runtime.
APP_STL = gnustl_static
example/jni/example.cpp
0 → 120000
View file @
96267654
..
/
example
.
cpp
\ No newline at end of file
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