1 # This file is part of NIT (http://www.nitlanguage.org).
3 # Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Advanced Android logging services
18 module log
is ldflags
"-llog"
23 #include <android/log.h>
26 # Use Android logs to print
27 redef fun print
(object
)
29 log_write
(priority_info
, app
.log_prefix
.to_cstring
, object
.to_s
.to_cstring
)
32 # Use Android logs to print errors
33 redef fun print_error
(object
)
35 log_write
(priority_error
, app
.log_prefix
.to_cstring
, object
.to_s
.to_cstring
)
38 # Use Android logs to print warnings
39 redef fun print_warning
(object
)
41 log_write
(priority_warn
, app
.log_prefix
.to_cstring
, object
.to_s
.to_cstring
)
45 # Prefix to all log messages
46 protected fun log_prefix
: String do return "app.nit"
49 # Default Android log priority
50 private fun priority_default
: Int do return 1
52 # Verbose Android log priority
53 private fun priority_verbose
: Int do return 2
55 # Debug Android log priority
56 private fun priority_debug
: Int do return 3
58 # Info Android log priority
59 private fun priority_info
: Int do return 4
61 # Warn Android log priority
62 private fun priority_warn
: Int do return 5
64 # Error Android log priority
65 private fun priority_error
: Int do return 6
67 # Fatal Android log priority
68 private fun priority_fatal
: Int do return 7
70 # Silent Android log priority
71 private fun priority_silent
: Int do return 8
73 # Write `text` to Android log at priority `level` with tag `tag`
74 private fun log_write
(level
: Int, tag
, text
: CString) `{
75 __android_log_write(level, tag, text);