close logfile at exit
This commit is contained in:
parent
050b0f7ea5
commit
d785a260d9
1 changed files with 6 additions and 2 deletions
8
log.cpp
8
log.cpp
|
@ -35,6 +35,8 @@ void setlog(const char *lf, const log_level_t ll_file, const log_level_t ll_scre
|
||||||
|
|
||||||
log_level_file = ll_file;
|
log_level_file = ll_file;
|
||||||
log_level_screen = ll_screen;
|
log_level_screen = ll_screen;
|
||||||
|
|
||||||
|
atexit(closelog);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setloguid(const int uid, const int gid)
|
void setloguid(const int uid, const int gid)
|
||||||
|
@ -45,9 +47,11 @@ void setloguid(const int uid, const int gid)
|
||||||
|
|
||||||
void closelog()
|
void closelog()
|
||||||
{
|
{
|
||||||
fclose(lfh);
|
if (lfh) {
|
||||||
|
fclose(lfh);
|
||||||
|
|
||||||
lfh = nullptr;
|
lfh = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void dolog(const log_level_t ll, const char *fmt, ...)
|
void dolog(const log_level_t ll, const char *fmt, ...)
|
||||||
|
|
Loading…
Add table
Reference in a new issue