Skip to content

Instantly share code, notes, and snippets.

@taxilian
Created October 15, 2011 04:14
Show Gist options
  • Save taxilian/1289031 to your computer and use it in GitHub Desktop.
Save taxilian/1289031 to your computer and use it in GitHub Desktop.
Example of adding a file-based logging method
#include <boost/filesystem.hpp>
#include "SystemHelpers.h"
using namespace boost::filesystem;
/// ...
void getLoggingMethods( FB::Log::LogMethodList& outMethods )
{
path appDataPath = FB::System::getLocalAppDataPath("CompanyName");
path logDirPath = appDataPath / "logs";
if (exists(logDirPath) && is_directory(logDirPath)) {
std::stringstream ss;
time_t seconds = time(NULL);
boost::thread::id threadId = boost::this_thread::get_id();
ss << seconds << "_" << threadId << ".log";
path logPath = logDirPath / ss.str();
fprintf(stderr, "logging to %s", logPath.string().c_str());
outMethods.push_back(std::make_pair(FB::Log::LogMethod_File, logPath.string()));
}
#ifndef NDEBUG
outMethods.push_back(std::make_pair(FB::Log::LogMethod_Console, std::string()));
#endif
}
// ...
@kangear
Copy link

kangear commented Oct 27, 2019

how about linux ?

@kangear
Copy link

kangear commented Oct 27, 2019

got it, the reason was *.so has not be update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment