mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 23:13:00 +02:00
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
55 lines
879 B
C++
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);
|
|
}
|
|
}
|
|
|