BitLab 0.1.0
BitLab: A Browser for the Bitcoin P2P Network and Blockchain
|
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <pthread.h>
Go to the source code of this file.
Data Structures | |
struct | logger |
The logger structure used to store the logger for the logging system. More... | |
struct | loggers |
The loggers structure used to store the loggers for the logging system. More... | |
Macros | |
#define | MAX_LOG_FILES 10 |
#define | MAX_FILENAME_LENGTH 256 |
#define | BITLAB_LOG "bitlab.log" |
#define | LOG_BITLAB_STARTED "BitLab started ----------------------------------------------------------------------------------------" |
#define | LOG_BITLAB_FINISHED "BitLab finished successfully" |
#define | LOCKED_FILE_RETRY_TIME 1000 |
#define | LOCKED_FILE_TIMEOUT 5000000 |
Typedefs | |
typedef struct logger | logger |
The logger structure used to store the logger for the logging system. | |
typedef struct loggers | loggers |
The loggers structure used to store the loggers for the logging system. | |
Enumerations | |
enum | log_level { LOG_DEBUG , LOG_INFO , LOG_WARN , LOG_ERROR , LOG_FATAL } |
The log level enumeration used to define the level of logging that is being used. More... | |
Functions | |
const char * | create_logs_dir () |
Create logs directory used to create the logs directory if it does not exist. | |
void | init_logging (const char *filename) |
Initialize logging used to initialize the logging system, open and preserve the log file. | |
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. | |
void | finish_logging () |
Finish logging used to finish logging and close the log file. | |
#define LOG_BITLAB_STARTED "BitLab started ----------------------------------------------------------------------------------------" |
The logger structure used to store the logger for the logging system.
filename | The filename of the log file. |
file | The file pointer for the log file. |
The loggers structure used to store the loggers for the logging system.
log_mutex | The mutex for the loggers. |
array | The array of loggers. |
is_initializing | The flag to indicate if the loggers are initializing. |
enum log_level |
The log level enumeration used to define the level of logging that is being used.
LOG_DEBUG | Debug level logging |
LOG_INFO | Information level logging |
LOG_WARN | Warning level logging |
LOG_ERROR | Error level logging |
LOG_FATAL | Fatal level logging |
Enumerator | |
---|---|
LOG_DEBUG | |
LOG_INFO | |
LOG_WARN | |
LOG_ERROR | |
LOG_FATAL |
const char * create_logs_dir | ( | ) |
Create logs directory used to create the logs directory if it does not exist.
Definition at line 20 of file log.c.
References logs_dir.
Referenced by init_logging(), and log_message().
void finish_logging | ( | ) |
Finish logging used to finish logging and close the log file.
Definition at line 199 of file log.c.
References loggers::array, logger::file, logger::filename, loggers::is_initializing, loggers::log_mutex, logs, logs_dir, MAX_LOG_FILES, and usleep().
Referenced by run_bitlab().
void init_logging | ( | const char * | filename | ) |
Initialize logging used to initialize the logging system, open and preserve the log file.
log_file | The log file to write to. |
Definition at line 34 of file log.c.
References loggers::array, BUFFER_SIZE, create_logs_dir(), logger::file, logger::filename, loggers::is_initializing, loggers::log_mutex, logs, logs_dir, and MAX_LOG_FILES.
Referenced by connect_to_peer(), and run_bitlab().
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.
level | The log level. |
log_file | The file that the log message is destined for. |
source_file | The source file that the log message is from. |
format | The format of the log message. |
... | The arguments for the format. |
Definition at line 89 of file log.c.
References loggers::array, BUFFER_SIZE, create_logs_dir(), logger::file, logger::filename, fileno(), get_formatted_timestamp(), LOCKED_FILE_RETRY_TIME, LOCKED_FILE_TIMEOUT, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, loggers::log_mutex, LOG_WARN, logs, logs_dir, MAX_LOG_FILES, TIMESTAMP_LENGTH, and usleep().
Referenced by add_peer_to_queue(), build_inv_message(), cli_clear(), cli_connect(), cli_disconnect(), cli_echo(), cli_exec_line(), cli_exit(), cli_getaddr(), cli_getblocks(), cli_getdata(), cli_getheaders(), cli_help(), cli_history(), cli_info(), cli_inv(), cli_list(), cli_peer_discovery(), cli_ping(), cli_tx(), cli_whoami(), connect_to_peer(), disconnect(), force_stop_peer_discovery(), handle_cli(), handle_inv_message(), handle_peer_discovery(), init_program_state(), is_in_private_network(), is_valid_domain_address(), lookup_address(), peer_communication(), run_bitlab(), send_addr(), send_getaddr_and_wait(), send_getblocks_and_wait(), send_getdata_and_wait(), send_getheaders_and_wait(), send_headers(), send_inv_and_wait(), send_ping(), send_tx(), send_verack(), set_peer_discovery(), set_peer_discovery_dns_domain(), start_peer_discovery_progress(), thread_runner(), and write_var_int().