I wrote this log function and it works but is there a better way to write into the file stream and console at the same time?
//The function
void log(int lvl, const char * format, ...) {
    va_list args;
    va_start(args, format);
    //If lvl < 0 the prefix will not be used
    if (lvl>=lINFO) {
        time_t now = time(NULL);
        struct tm tm = *localtime(&now);
        //Printing to the console
        printf("[%d-%02d-%02d %02d:%02d:%02d %s] [%s] : ",
             tm.tm_year+1900,
             tm.tm_mon+1,
             tm.tm_mday,
             tm.tm_hour,
             tm.tm_min,
             tm.tm_sec,
             __log_name,
             parse_lvl(lvl)
        );
        //Printing into the file
        //Checking if NULL(if yes the file wont be used)
        if(__log_filestream)
            fprintf(__log_filestream,
                "[%d-%02d-%02d %02d:%02d:%02d %s] [%s] : ",
                 tm.tm_year+1900,
                 tm.tm_mon+1,
                 tm.tm_mday,
                 tm.tm_hour,
                 tm.tm_min,
                 tm.tm_sec,
                 __log_name,
                 parse_lvl(lvl)
            );
    }
    //Printing to the console
    vprintf(format, args);
    printf("\n");
    //Printing into the file
    if (__log_filestream) {
        vfprintf(__log_filestream, format, args);
        fprintf(__log_filestream, "\n");
    }
    va_end(args);
}
```


