lib/app & android: move log_prefix to Android, where it is used
[nit.git] / lib / android / log.nit
1 # This file is part of NIT (http://www.nitlanguage.org).
2 #
3 # Copyright 2014 Alexis Laferrière <alexis.laf@xymus.net>
4 #
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
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16
17 # Advanced Android logging services
18 module log is ldflags "-llog"
19
20 import platform
21
22 in "C" `{
23 #include <android/log.h>
24 `}
25
26 redef class App
27 # Prefix to all log messages
28 protected fun log_prefix: String do return "app.nit"
29 end
30
31 # Default Android log priority
32 fun priority_default: Int do return 1
33
34 # Verbose Android log priority
35 fun priority_verbose: Int do return 2
36
37 # Debug Android log priority
38 fun priority_debug: Int do return 3
39
40 # Info Android log priority
41 fun priority_info: Int do return 4
42
43 # Warn Android log priority
44 fun priority_warn: Int do return 5
45
46 # Error Android log priority
47 fun priority_error: Int do return 6
48
49 # Fatal Android log priority
50 fun priority_fatal: Int do return 7
51
52 # Silent Android log priority
53 fun priority_silent: Int do return 8
54
55 # Write `text` to Android log at priority `level` with tag `tag`
56 fun log_write(level: Int, tag, text: NativeString) `{
57 __android_log_write(level, tag, text);
58 `}