1 /*
2                                     __
3                                    / _|
4   __ _ _   _ _ __ ___  _ __ __ _  | |_ ___  ___ ___
5  / _` | | | | '__/ _ \| '__/ _` | |  _/ _ \/ __/ __|
6 | (_| | |_| | | | (_) | | | (_| | | || (_) \__ \__ \
7  \__,_|\__,_|_|  \___/|_|  \__,_| |_| \___/|___/___/
8 
9 Copyright (C) 2009 The Android Open Source Project.
10 Copyright (C) 2018-2019 Aurora Free Open Source Software.
11 
12 This file is part of the Aurora Free Open Source Software. This
13 organization promote free and open source software that you can
14 redistribute and/or modify under the terms of the GNU Lesser General
15 Public License Version 3 as published by the Free Software Foundation or
16 (at your option) any later version approved by the Aurora Free Open Source
17 Software Organization. The license is available in the package root path
18 as 'LICENSE' file. Please review the following information to ensure the
19 GNU Lesser General Public License version 3 requirements will be met:
20 https://www.gnu.org/licenses/lgpl.html .
21 
22 Alternatively, this file may be used under the terms of the GNU General
23 Public License version 3 or later as published by the Free Software
24 Foundation. Please review the following information to ensure the GNU
25 General Public License requirements will be met:
26 https://www.gnu.org/licenses/gpl-3.0.html.
27 
28 NOTE: All products, services or anything associated to trademarks and
29 service marks used or referenced on this file are the property of their
30 respective companies/owners or its subsidiaries. Other names and brands
31 may be claimed as the property of others.
32 
33 For more info about intellectual property visit: aurorafoss.org or
34 directly send an email to: contact (at) aurorafoss.org .
35 
36 This file has bindings for an existing code, part of The Android Open Source
37 Project implementation. Check it out at android.googlesource.com .
38 */
39 
40 module aurorafw.android.platform.log;
41 
42 import core.stdc.stdarg;
43 
44 version (Android):
45 extern (C):
46 @system:
47 nothrow:
48 @nogc:
49 
50 /******************************************************************
51  *
52  * IMPORTANT NOTICE:
53  *
54  *   This file is part of Android's set of stable system headers
55  *   exposed by the Android NDK (Native Development Kit) since
56  *   platform release 1.5
57  *
58  *   Third-party source AND binary code relies on the definitions
59  *   here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES.
60  *
61  *   - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES)
62  *   - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS
63  *   - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY
64  *   - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES
65  */
66 
67 /**
68  * @addtogroup Logging
69  * @{
70  */
71 
72 /**
73  * \file
74  *
75  * Support routines to send messages to the Android log buffer,
76  * which can later be accessed through the `logcat` utility.
77  *
78  * Each log message must have
79  *   - a priority
80  *   - a log tag
81  *   - some text
82  *
83  * The tag normally corresponds to the component that emits the log message,
84  * and should be reasonably small.
85  *
86  * Log message text may be truncated to less than an implementation-specific
87  * limit (1023 bytes).
88  *
89  * Note that a newline character ("\n") will be appended automatically to your
90  * log message, if not already there. It is not possible to send several
91  * messages and have them appear on a single line in logcat.
92  *
93  * Please use logging in moderation:
94  *
95  *  - Sending log messages eats CPU and slow down your application and the
96  *    system.
97  *
98  *  - The circular log buffer is pretty small, so sending many messages
99  *    will hide other important log messages.
100  *
101  *  - In release builds, only send log messages to account for exceptional
102  *    conditions.
103  */
104 
105 /**
106  * Android log priority values, in increasing order of priority.
107  */
108 enum android_LogPriority
109 {
110     /** For internal use only.  */
111     ANDROID_LOG_UNKNOWN = 0,
112     /** The default priority, for internal use only.  */
113     ANDROID_LOG_DEFAULT = 1, /* only for SetMinPriority() */
114     /** Verbose logging. Should typically be disabled for a release apk. */
115     ANDROID_LOG_VERBOSE = 2,
116     /** Debug logging. Should typically be disabled for a release apk. */
117     ANDROID_LOG_DEBUG = 3,
118     /** Informational logging. Should typically be disabled for a release apk. */
119     ANDROID_LOG_INFO = 4,
120     /** Warning logging. For use with recoverable failures. */
121     ANDROID_LOG_WARN = 5,
122     /** Error logging. For use with unrecoverable failures. */
123     ANDROID_LOG_ERROR = 6,
124     /** Fatal logging. For use when aborting. */
125     ANDROID_LOG_FATAL = 7,
126     /** For internal use only.  */
127     ANDROID_LOG_SILENT = 8 /* only for SetMinPriority(); must be last */
128 }
129 
130 /**
131  * Writes the constant string `text` to the log, with priority `prio` and tag
132  * `tag`.
133  */
134 int __android_log_write (int prio, const(char)* tag, const(char)* text);
135 
136 /**
137  * Writes a formatted string to the log, with priority `prio` and tag `tag`.
138  * The details of formatting are the same as for
139  * [printf(3)](http://man7.org/linux/man-pages/man3/printf.3.html).
140  */
141 int __android_log_print (int prio, const(char)* tag, const(char)* fmt, ...);
142 
143 /**
144  * Equivalent to `__android_log_print`, but taking a `va_list`.
145  * (If `__android_log_print` is like `printf`, this is like `vprintf`.)
146  */
147 int __android_log_vprint (
148     int prio,
149     const(char)* tag,
150     const(char)* fmt,
151     va_list ap);
152 
153 /**
154  * Writes an assertion failure to the log (as `ANDROID_LOG_FATAL`) and to
155  * stderr, before calling
156  * [abort(3)](http://man7.org/linux/man-pages/man3/abort.3.html).
157  *
158  * If `fmt` is non-null, `cond` is unused. If `fmt` is null, the string
159  * `Assertion failed: %s` is used with `cond` as the string argument.
160  * If both `fmt` and `cond` are null, a default string is provided.
161  *
162  * Most callers should use
163  * [assert(3)](http://man7.org/linux/man-pages/man3/assert.3.html) from
164  * `<assert.h>` instead, or the `__assert` and `__assert2` functions provided by
165  * bionic if more control is needed. They support automatically including the
166  * source filename and line number more conveniently than this function.
167  */
168 void __android_log_assert (
169     const(char)* cond,
170     const(char)* tag,
171     const(char)* fmt,
172     ...);
173 
174 enum log_id
175 {
176     LOG_ID_MIN = 0,
177 
178     LOG_ID_MAIN = 0,
179     LOG_ID_RADIO = 1,
180     LOG_ID_EVENTS = 2,
181     LOG_ID_SYSTEM = 3,
182     LOG_ID_CRASH = 4,
183     LOG_ID_STATS = 5,
184     LOG_ID_SECURITY = 6,
185     LOG_ID_KERNEL = 7, /* place last, third-parties can not use it */
186 
187     LOG_ID_MAX = 8
188 }
189 
190 alias log_id_t = log_id;
191 
192 /*
193  * Send a simple string to the log.
194  */
195 int __android_log_buf_write (
196     int bufID,
197     int prio,
198     const(char)* tag,
199     const(char)* text);
200 int __android_log_buf_print (
201     int bufID,
202     int prio,
203     const(char)* tag,
204     const(char)* fmt,
205     ...);
206 
207 /** @} */
208 
209 /* _ANDROID_LOG_H */