c code snippets - Serbipunk/notes GitHub Wiki

raw log

#include <ctime>
#include <iomanip>

void appendLog(const std::string& msg)
{
    // Get the current time
    std::time_t now = std::time(nullptr);
    // Convert to local time
    std::tm *ltm = std::localtime(&now);
    std::ofstream ofile("/tmp/pybind_log.txt", std::ios::out | std::ios::app);
    ofile << std::put_time(ltm, "%Y-%m-%d %H:%M:%S") << "  :  " << msg << std::endl;
    ofile.close();
}
⚠️ **GitHub.com Fallback** ⚠️