Contiki 2.5
logging.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012, Daniel Willmann <daniel@totalueberwachung.de>
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the Institute nor the names of its contributors
14  * may be used to endorse or promote products derived from this software
15  * without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  * This file is part of the Contiki operating system.
30  *
31  * @(#)$Id: $
32  */
33 /**
34  * \addtogroup logging
35  * @{
36  */
37 
38 /**
39  * \defgroup logging Logging subsystem
40  *
41  * The logging subsystem allows different logdomains to be configured.
42  * For each of these logdomains the verbosity of the output can be set
43  * during runtime.
44  *
45  * @{
46  */
47 
48 /**
49  * \file
50  * Header file for the logging subsystem
51  * \author
52  * Daniel Willmann <daniel@totalueberwachung.de>
53  *
54  */
55 
56 #ifndef __LOGGING_H__
57 #define __LOGGING_H__
58 
59 #include <stdio.h>
60 
61 #define LOGL_DBG 0
62 #define LOGL_INF 1
63 #define LOGL_WRN 2
64 #define LOGL_ERR 3
65 #define LOGL_CRI 4
66 #define LOGL_NUM 5 /* Always last! */
67 
68 #define LOGD_CORE 0
69 #define LOGD_CPU 1
70 #define LOGD_INGA 2
71 #define LOGD_APP 3
72 #define LOGD_DTN 4
73 #define LOGD_NUM 5 /* Always last! */
74 
75 #ifdef ENABLE_LOGGING
76 /*---------------------------------------------------------------------------*/
77 /**
78  * \brief Log a message
79  * \param logdom log domain of the message
80  * \param sdom subdomain of the message
81  * \param logl log level of the message
82  * \author Daniel Willmann
83  *
84  * This macro is used to pring a log message of a given level and domain
85  *
86  * \hideinitializer
87  */
88 #define LOG(logdom, sdom, logl, fmt, ...) do { \
89  logging_logfn(logdom, sdom, logl, "[%s:%s](%s:%d): " fmt, logging_level2str(logl), \
90  logging_dom2str(logdom), __func__, __LINE__, ## __VA_ARGS__); \
91  } while (0)
92 #else
93 #define LOG(...)
94 #endif
95 
96 void logging_init(void);
97 void logging_domain_level_set(uint8_t logdom, uint8_t sdom, uint8_t logl);
98 void logging_logfn(uint8_t logdom, uint8_t logl, uint8_t sdom, const char *fmt, ...);
99 const char *logging_dom2str(uint8_t logdom);
100 const char *logging_level2str(uint8_t logl);
101 void logging_hexdump(uint8_t *data, unsigned int len);
102 
103 #endif /* __LOGGING_H__ */
104 
105 /** @} */
106 /** @} */