#include "stdafx.h"
#include "spdlog/spdlog.h"
#include "spdlog/sinks/basic_file_sink.h"
#include "spdlog/sinks/stdout_color_sinks.h"
#include <Shlobj.h>

char logfile[MAX_PATH];
const char * GetLogFilename()
{
	char szPath[MAX_PATH];
	if (SUCCEEDED(SHGetFolderPathA(NULL, CSIDL_APPDATA, NULL, 0, szPath)))
	{
		PathCombineA(logfile, szPath, "Valgdirektoratet\\EVA Skanning\\com-surrogate-scanning-log.txt");
	}

	return logfile;
}

std::shared_ptr<spdlog::logger> GetLogger()
{
	try
	{
		return spdlog::basic_logger_mt("basic_logger", GetLogFilename()); 
	}
	catch (const std::exception&)
	{
		return spdlog::stdout_color_mt("console");
	}
}

std::shared_ptr<spdlog::logger> logg = GetLogger();

