solo1/fido2/log.h

84 wiersze
2.2 KiB
C
Czysty Zwykły widok Historia

2018-09-13 21:58:34 +00:00
/*
2018-12-17 00:05:33 +00:00
* Copyright (C) 2018 SoloKeys, Inc. <https://solokeys.com/>
*
* This file is part of Solo.
*
* Solo is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Solo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Solo. If not, see <https://www.gnu.org/licenses/>
*
* This code is available under licenses for commercial use.
* Please contact SoloKeys for more information.
*/
2018-05-15 02:55:47 +00:00
#ifndef _LOG_H
#define _LOG_H
2018-12-03 04:31:34 +00:00
#include APP_CONFIG
2018-09-10 20:27:15 +00:00
#include <stdint.h>
2018-07-15 16:24:32 +00:00
#ifndef DEBUG_LEVEL
#define DEBUG_LEVEL 0
#endif
2018-05-15 02:55:47 +00:00
#define ENABLE_FILE_LOGGING
2018-05-18 15:40:17 +00:00
void LOG(uint32_t tag, const char * filename, int num, const char * fmt, ...);
void LOG_HEX(uint32_t tag, uint8_t * data, int length);
2018-12-03 05:14:26 +00:00
2018-06-02 18:44:12 +00:00
void set_logging_tag(uint32_t tag);
2018-05-18 15:40:17 +00:00
typedef enum
{
2018-06-04 23:35:34 +00:00
TAG_GEN = (1 << 0),
TAG_MC = (1 << 1),
TAG_GA = (1 << 2),
TAG_CP = (1 << 3),
TAG_ERR = (1 << 4),
TAG_PARSE= (1 << 5),
TAG_CTAP = (1 << 6),
TAG_U2F = (1 << 7),
TAG_DUMP = (1 << 8),
TAG_GREEN = (1 << 9),
TAG_RED= (1 << 10),
TAG_TIME= (1 << 11),
TAG_HID = (1 << 12),
TAG_USB = (1 << 13),
2018-07-08 02:43:06 +00:00
TAG_WALLET = (1 << 14),
2018-07-12 01:55:20 +00:00
TAG_STOR = (1 << 15),
2018-11-12 16:51:43 +00:00
TAG_DUMP2 = (1 << 16),
2018-12-03 04:31:34 +00:00
TAG_BOOT = (1 << 17),
TAG_EXT = (1 << 17),
2018-05-18 15:40:17 +00:00
TAG_FILENO = (1<<31)
} LOG_TAG;
2018-05-15 02:55:47 +00:00
2018-12-03 05:14:26 +00:00
#if DEBUG_LEVEL > 0
2018-05-15 02:55:47 +00:00
2018-12-03 05:14:26 +00:00
void set_logging_mask(uint32_t mask);
2018-05-18 15:40:17 +00:00
#define printf1(tag,fmt, ...) LOG(tag & ~(TAG_FILENO), NULL, 0, fmt, ##__VA_ARGS__)
#define printf2(tag,fmt, ...) LOG(tag | TAG_FILENO,__FILE__, __LINE__, fmt, ##__VA_ARGS__)
#define printf3(tag,fmt, ...) LOG(tag | TAG_FILENO,__FILE__, __LINE__, fmt, ##__VA_ARGS__)
#define dump_hex1(tag,data,len) LOG_HEX(tag,data,len)
2018-05-15 02:55:47 +00:00
#else
2018-12-03 05:14:26 +00:00
#define set_logging_mask(mask)
2018-05-15 02:55:47 +00:00
#define printf1(fmt, ...)
#define printf2(fmt, ...)
#define printf3(fmt, ...)
2018-07-15 16:24:32 +00:00
#define dump_hex1(tag,data,len)
2018-05-15 02:55:47 +00:00
#endif
#endif