Files
recycled-ni-neutrino/lib/libdvbsub/Debug.cpp
vanhofen d12834b470 libdvbsub: fix compiler warning: ‘int ftime(timeb*)’ is deprecated
Origin commit data
------------------
Branch: ni/coolstream
Commit: aa7c356582
Author: vanhofen <vanhofen@gmx.de>
Date: 2023-01-25 (Wed, 25 Jan 2023)

Origin message was:
------------------
- libdvbsub: fix compiler warning: ‘int ftime(timeb*)’ is deprecated

------------------
No further description and justification available within origin commit message!

------------------
This commit was generated by Migit
2023-01-25 23:43:26 +01:00

55 lines
879 B
C++

#include <sys/time.h>
#include <time.h>
#include <cstdio>
#include <cstdarg>
#include "Debug.hpp"
Debug::Debug() :
file_(const_cast<char *>("")), level_(0), fp_(stdout)
{
}
Debug::~Debug()
{
if (fp_ && fp_ != stdout) {
fclose(fp_);
}
}
void Debug::set_level(int level)
{
level_ = level;
}
FILE* Debug::set_file(char* file)
{
FILE* fp = fopen(file, "a");
if (!fp) {
return NULL;
}
fp_ = fp;
return fp_;
}
void Debug::print(int level, const char *fmt, ...)
{
va_list argp;
struct timeval tv;
char buf[1024];
char tbuf[20];
int len;
if (level < level_) {
gettimeofday(&tv, NULL);
strftime(tbuf, sizeof(tbuf), "%H:%M:%S", localtime(&tv.tv_sec));
len = sprintf(buf, "[ %s.%03ld ] ", tbuf, tv.tv_usec / 1000);
va_start(argp, fmt);
//vfprintf(fp_, fmt, argp);
vsnprintf (&buf[len], 512, fmt, argp);
va_end(argp);
fprintf(fp_, "%s", buf);
}
}