Derive-C
Loading...
Searching...
No Matches
trait.h
Go to the documentation of this file.
1#pragma once
2
4
12
14 switch (level) {
15 case DC_TRACE:
16 return "TRACE";
17 case DC_DEBUG:
18 return "DEBUG";
19 case DC_INFO:
20 return "INFO";
21 case DC_WARN:
22 return "WARN";
23 case DC_ERROR:
24 return "ERROR";
25 }
26 return "UNKNOWN";
27}
28
29typedef struct {
30 char const* file;
31 int line;
33
34#define DC_LOCATION \
35 (dc_log_location) { __FILE__, __LINE__ }
36
37#define DC_LOG_ID_LENGTH 32
38
39typedef struct {
41} dc_log_id;
42
43#define DC_TRAIT_LOGGER(SELF) \
44 DC_REQUIRE_TYPE(SELF, global_config); \
45 DC_REQUIRE_METHOD(SELF, SELF, new_global, (NS(SELF, global_config), dc_log_id id)); \
46 DC_REQUIRE_METHOD(SELF, SELF, from_parent, (SELF * parent, dc_log_id id)); \
47 DC_REQUIRE_METHOD(void, SELF, log, \
48 (SELF*, dc_log_location, dc_log_level, const char* const, ...)); \
49 DC_TRAIT_DELETABLE(SELF); \
50 DC_TRAIT_DEBUGABLE(SELF)
#define DC_DEBUG(DEBUG_FN, DEBUG_PTR)
Definition dump.h:92
#define DC_PUBLIC
Definition namespace.h:25
char name[DC_LOG_ID_LENGTH]
Definition trait.h:40
char const * file
Definition trait.h:30
dc_log_level
Definition trait.h:5
@ DC_INFO
Definition trait.h:8
@ DC_TRACE
Definition trait.h:6
@ DC_ERROR
Definition trait.h:10
@ DC_WARN
Definition trait.h:9
static DC_PUBLIC char const * dc_log_level_to_string(dc_log_level level)
Definition trait.h:13
#define DC_LOG_ID_LENGTH
Definition trait.h:37