1 /**
2  * \file
3  * \brief Log C interface.
4  */
5 /*
6  * (c) 2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
7  *     economic rights: Technische Universität Dresden (Germany)
8  *
9  * This file is part of TUD:OS and distributed under the terms of the
10  * GNU General Public License 2.
11  * Please see the COPYING-GPL-2 file for details.
12  *
13  * As a special exception, you may use this file as part of a free software
14  * library without restriction.  Specifically, if other files instantiate
15  * templates or use macros or inline functions from this file, or you compile
16  * this file and link it with other files to produce an executable, this
17  * file does not by itself cause the resulting executable to be covered by
18  * the GNU General Public License.  This exception does not however
19  * invalidate any other reasons why the executable file might be covered by
20  * the GNU General Public License.
21  */
22 #pragma once
23 
24 /**
25  * \defgroup api_l4re_c_log Log interface
26  * \ingroup api_l4re_c
27  * \brief Log C interface.
28  */
29 
30 #include <l4/re/env.h>
31 
32 EXTERN_C_BEGIN
33 
34 /**
35  * \ingroup api_l4re_c_log
36  * \brief Write a null terminated string to the default log.
37  *
38  * \param string     Text to print, null terminated.
39  *
40  * \return 0 for success, <0 on error
41  *
42  * \see L4Re::Log::print
43  */
44 L4_CV L4_INLINE void
45 l4re_log_print(char const *string) L4_NOTHROW;
46 
47 /**
48  * \ingroup api_l4re_c_log
49  * \brief Write a string of a given length to the default log.
50  *
51  * \param string     Text to print, null terminated.
52  * \param len        Length of string in bytes.
53  *
54  * \return 0 for success, <0 on error
55  *
56  * \see L4Re::Log::printn
57  */
58 L4_CV L4_INLINE void
59 l4re_log_printn(char const *string, int len) L4_NOTHROW;
60 
61 
62 
63 
64 /**
65  * \ingroup api_l4re_c_log
66  * \brief Write a null terminated string to a log.
67  *
68  * \param logcap     Log capability (service).
69  * \param string     Text to print, null terminated.
70  *
71  * \return 0 for success, <0 on error
72  *
73  * \see L4Re::Log::print
74  */
75 L4_CV void
76 l4re_log_print_srv(const l4_cap_idx_t logcap,
77                    char const *string) L4_NOTHROW;
78 
79 /**
80  * \ingroup api_l4re_c_log
81  * \brief Write a string of a given length to a log.
82  *
83  * \param logcap     Log capability (service).
84  * \param string     Text to print, null terminated.
85  * \param len        Length of string in bytes.
86  *
87  * \return 0 for success, <0 on error
88  *
89  * \see L4Re::Log::printn
90  */
91 L4_CV void
92 l4re_log_printn_srv(const l4_cap_idx_t logcap,
93                     char const *string, int len) L4_NOTHROW;
94 
95 
96 /********** Implementations ***************************/
97 
98 L4_CV L4_INLINE void
l4re_log_print(char const * string)99 l4re_log_print(char const *string) L4_NOTHROW
100 {
101   l4re_log_print_srv(l4re_global_env->log, string);
102 }
103 
104 L4_CV L4_INLINE void
l4re_log_printn(char const * string,int len)105 l4re_log_printn(char const *string, int len) L4_NOTHROW
106 {
107   l4re_log_printn_srv(l4re_global_env->log, string, len);
108 }
109 
110 EXTERN_C_END
111