You are browsing as a guest. Sign up (or log in) to start making projects!

2h 22m 56s logged

More work on the logging system. Realized that we can use a global var with an init function to remove the need for each log call to pass the file pointer to the log

Previous Method;

// main
log_err(errno, "client/main", fptr);

The fptr is a FILE* varible that points to the logging file

New Method;

// log.c
static FILE *log_file = NULL;

int log_init(const char *file_path) {
    log_file = fopen(file_path, "a");

    if(log_file == NULL) {
        log_err(errno, "log/log_init");
        return -1;
    }
    return 0;
}

// main
log_init("log/log.txt");

log_err(errno, "client/main");

The new method means all you have to pass is errno and the location of error.

Super Simple!!!

I also updated both client and server with this system.

Bye

0
4

Comments 0

No comments yet. Be the first!