VideoCodec/Logger.h
#ifndef LOGGER_H_
#define LOGGER_H_
#include <iostream>
#include <stdio.h>
#include <stdarg.h>
#include "Data/Constants.h"
#ifdef DEBUG
#define DEBUG_OUTPUT
#endif
using namespace std;
namespace VideoCodec
{
class Logger
{
public:
Logger();
virtual ~Logger();
static void LogMessage(const char* format, ...)
{
va_list args;
va_start(args, format);
// Write to the file or to STDOUT.
cout << "Log message ";
vfprintf(stdout, format, args);
va_end(args);
cout << '\n';
};
static void BeginIncrementalLogMessage(const char* text)
{
cout << "Begin log information " << text << '\n';
};
static void IncrementalLogMessage(const char* text)
{
cout << text;
};
static void IncrementalLogMessage(int value)
{
cout << value;
};
static void IncrementalLogMessage(float value)
{
cout << value;
};
static void EndIncrementalLogMessage(const char* text)
{
cout << "\nEnd log information " << text << '\n';
};
static void DebugLog(const char* format, ...)
{
#ifdef DEBUG_OUTPUT
va_list args;
va_start(args, format);
// Write to the file or to STDOUT.
//vprintf(format, args);
vfprintf(debugFile, format, args);
va_end(args);
#endif
}
static void InitializeLogging()
{
#ifdef DEBUG_OUTPUT
debugFile = fopen("debugOut", "w");
#else
debugFile = NULL;
#endif
}
static void FinishLogging()
{
#ifdef DEBUG_OUTPUT
fclose(debugFile);
#endif
}
private:
static FILE* debugFile;
};
}
#endif /*LOGGER_H_*/