I am trying to create a c++ Logger, but I get 2 errors when I try to compile it. I tried to find a solution, but I didn't manage to find one. The only think I managed to find out is that it is a linking error, but I have no idea how to fix it.
Here is my code:
main.cpp
#include "logger.h"
int main()
{
Logger::Debug("h", "dog");
return 0;
}
logger.h
#pragma once
#include <iostream>
class Logger
{
private:
template<typename... Args>
static void Log(Args... args);
public:
template<typename... Args>
static void Debug(Args... args);
template<typename... Args>
static void Info(Args...args);
};
logger.cpp
#include "logger.h"
template<typename... Args>
static void Logger::Log(Args... args)
{
for (auto&& x : { args... })
{
std::cout << x << " ";
}
std::cout << std::endl;
}
template<typename... Args>
static void Logger::Debug(Args... args)
{
std::cout << "[Debug]\t";
Logger::Log(args...);
}
template<typename... Args>
static void Logger::Info(Args... args)
{
std::cout << "[Info]\t";
Logger::Log(args);
}
And here are my errors:
Please help. Thanks.