NimBLE-Arduino 2.1.2
Loading...
Searching...
No Matches
log_common.h
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19
20#ifndef H_LOG_COMMON_
21#define H_LOG_COMMON_
22
23#include <stdint.h>
24#include "ignore.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30struct log;
31
32#define LOG_VERSION_V3 3
33
34#define LOG_TYPE_STREAM (0)
35#define LOG_TYPE_MEMORY (1)
36#define LOG_TYPE_STORAGE (2)
37
38#define LOG_LEVEL_DEBUG (0)
39#define LOG_LEVEL_INFO (1)
40#define LOG_LEVEL_WARN (2)
41#define LOG_LEVEL_ERROR (3)
42#define LOG_LEVEL_CRITICAL (4)
43#define LOG_LEVEL_NONE (5)
44/* Up to 7 custom log levels. */
45#define LOG_LEVEL_MAX (15)
46
47#define LOG_LEVEL_STR(level) \
48 (LOG_LEVEL_DEBUG == level ? "DEBUG" :\
49 (LOG_LEVEL_INFO == level ? "INFO" :\
50 (LOG_LEVEL_WARN == level ? "WARN" :\
51 (LOG_LEVEL_ERROR == level ? "ERROR" :\
52 (LOG_LEVEL_CRITICAL == level ? "CRITICAL" :\
53 "UNKNOWN")))))
54
55/* XXX: These module IDs are defined for backwards compatibility. Application
56 * code should use the syscfg settings directly. These defines will be removed
57 * in a future release.
58 */
59#define LOG_MODULE_DEFAULT 0
60#define LOG_MODULE_OS 1
61#define LOG_MODULE_NEWTMGR 2
62#define LOG_MODULE_NIMBLE_CTLR 3
63#define LOG_MODULE_NIMBLE_HOST 4
64#define LOG_MODULE_NFFS 5
65#define LOG_MODULE_REBOOT 6
66#define LOG_MODULE_IOTIVITY 7
67#define LOG_MODULE_TEST 8
68
69#define LOG_MODULE_PERUSER 64
70#define LOG_MODULE_MAX (255)
71
72#define LOG_ETYPE_STRING (0)
73#define LOG_ETYPE_CBOR (1)
74#define LOG_ETYPE_BINARY (2)
75
76/* UTC Timestamp for Jan 2016 00:00:00 */
77#define UTC01_01_2016 1451606400
78
79#define LOG_NAME_MAX_LEN (64)
80
81#ifndef MYNEWT_VAL_LOG_LEVEL
82#define LOG_SYSLEVEL ((uint8_t)LOG_LEVEL_MAX)
83#else
84#define LOG_SYSLEVEL ((uint8_t)MYNEWT_VAL_LOG_LEVEL)
85#endif
86
100#define LOG_MOD_LEVEL_IS_ACTIVE(mod_level, entry_level) \
101 (LOG_LEVEL <= (entry_level) && (mod_level) <= (entry_level))
102
103/* Newtmgr Log opcodes */
104#define LOGS_NMGR_OP_READ (0)
105#define LOGS_NMGR_OP_CLEAR (1)
106#define LOGS_NMGR_OP_APPEND (2)
107#define LOGS_NMGR_OP_MODULE_LIST (3)
108#define LOGS_NMGR_OP_LEVEL_LIST (4)
109#define LOGS_NMGR_OP_LOGS_LIST (5)
110#define LOGS_NMGR_OP_SET_WATERMARK (6)
111#define LOGS_NMGR_OP_MODLEVEL (8)
112
113#define LOG_PRINTF_MAX_ENTRY_LEN (128)
114
115/* Global log info */
116struct log_info {
117#if MYNEWT_VAL(LOG_GLOBAL_IDX)
118 uint32_t li_next_index;
119#endif
120 uint8_t li_version;
121};
122
123extern struct log_info g_log_info;
124
132typedef void log_append_cb(struct log *log, uint32_t idx);
133
139typedef void log_notify_rotate_cb(const struct log *log);
140
141#ifdef __cplusplus
142}
143#endif
144
145#endif