BitLab 0.1.0
BitLab: A Browser for the Bitcoin P2P Network and Blockchain
Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1#ifndef __LOG_H
2#define __LOG_H
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <stdarg.h>
7#include <pthread.h>
8
9#define MAX_LOG_FILES 10
10#define MAX_FILENAME_LENGTH 256
11#define BITLAB_LOG "bitlab.log"
12#define LOG_BITLAB_STARTED "BitLab started ----------------------------------------------------------------------------------------"
13#define LOG_BITLAB_FINISHED "BitLab finished successfully"
14
15#define LOCKED_FILE_RETRY_TIME 1000 // in microseconds (1 millisecond)
16#define LOCKED_FILE_TIMEOUT 5000000 // in microseconds (5 seconds)
17
35
42typedef struct logger
43{
44 char* filename;
45 FILE* file;
47
55typedef struct loggers
56{
57 pthread_mutex_t log_mutex;
61
67const char* create_logs_dir();
68
74void init_logging(const char* filename);
75
85void log_message(log_level level, const char* filename, const char* source_file, const char* format, ...);
86
90void finish_logging();
91
92#endif // __LOG_H
void finish_logging()
Finish logging used to finish logging and close the log file.
Definition log.c:199
void log_message(log_level level, const char *filename, const char *source_file, const char *format,...)
Log a message used to log a message to the console or a file.
Definition log.c:89
#define MAX_LOG_FILES
Definition log.h:9
void init_logging(const char *filename)
Initialize logging used to initialize the logging system, open and preserve the log file.
Definition log.c:34
const char * create_logs_dir()
Create logs directory used to create the logs directory if it does not exist.
Definition log.c:20
log_level
The log level enumeration used to define the level of logging that is being used.
Definition log.h:28
@ LOG_ERROR
Definition log.h:32
@ LOG_INFO
Definition log.h:30
@ LOG_DEBUG
Definition log.h:29
@ LOG_FATAL
Definition log.h:33
@ LOG_WARN
Definition log.h:31
The logger structure used to store the logger for the logging system.
Definition log.h:43
char * filename
Definition log.h:44
FILE * file
Definition log.h:45
The loggers structure used to store the loggers for the logging system.
Definition log.h:56
logger * array[MAX_LOG_FILES]
Definition log.h:58
int is_initializing
Definition log.h:59
pthread_mutex_t log_mutex
Definition log.h:57