mmCEsim 0.3.0
mmWave Channel Estimation Simulation
log.h
Go to the documentation of this file.
1
12#ifndef _MMCESIM_LOG_LOG_H_
13#define _MMCESIM_LOG_LOG_H_
14
15#include "meta.h"
16#include "utils.h"
17#include <clip.h>
18#include <filesystem>
19#include <fstream>
20#include <iostream>
21
23
24static inline std::string logFileName() { return dataDir() + "/mmcesim.log"; }
25
31static inline std::string localLogFileName() {
32 std::filesystem::path p(logFileName());
33 return p.string();
34}
35
36static inline void printLog() {
37 std::ifstream f(logFileName());
38 if (!f.is_open()) {
39 // std::cerr << "[ERROR] Cannot open log file at '" << localLogFileName() << "'." << std::endl;
40 // exit(MMCESIM_LOG_ERR::CANNOT_OPEN_LOG_FILE);
41 return;
42 }
43 std::stringstream buf;
44 buf << f.rdbuf();
45 std::cout << buf.str() << std::endl;
46}
47
48static inline void copyLogToClipboard() {
49 std::ifstream f(logFileName());
50 if (!f.is_open()) {
51 // std::cerr << "[ERROR] Cannot open log file at '" << localLogFileName() << "'." << std::endl;
52 // exit(MMCESIM_LOG_ERR::CANNOT_OPEN_LOG_FILE);
53 return;
54 }
55 std::stringstream buf;
56 buf << f.rdbuf();
57 clip::set_text(buf.str());
58}
59
60#endif
mmCEsim meta data
MMCESIM_LOG_ERR
Definition: log.h:22
@ CANNOT_OPEN_LOG_FILE
Definition: log.h:22
static std::string logFileName()
Definition: log.h:24
static void printLog()
Definition: log.h:36
static std::string localLogFileName()
Get the log file name on the local machine.
Definition: log.h:31
static void copyLogToClipboard()
Definition: log.h:48
Utilities.
static std::string dataDir()
Definition: utils.h:162