#include #include #include #include #include #include #include #include std::string LOG_DIR = "/log_data"; void log(std::string msg) { mkdir(LOG_DIR.c_str(), 0755); time_t now = time(0); struct tm tstruct; tstruct = *localtime(&now); char filename[12]; std::strftime(filename, 12, "%Y-%m-%d", &tstruct); std::ofstream log_file; log_file.open(LOG_DIR + "/" + filename + ".log", std::ios_base::app); char timestamp[32]; std::strftime(timestamp, 32, "%Y/%m/%d %H:%M:%S ", &tstruct); log_file << timestamp << msg << std::endl; log_file.close(); } int main() { log("uwu"); log("owo"); log("yay"); return 0; }