summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBossCode45 <human.cyborg42@gmail.com>2023-06-23 11:51:45 +1200
committerBossCode45 <human.cyborg42@gmail.com>2023-06-23 11:51:45 +1200
commit87b7f6c47d8eab8bfe7f126652a88939aac58a6a (patch)
tree4c0642fc3a41a2593fff2e73a6017385b83e24c0
parent6a9f1b77d3a815afa870386d626fb01dceed944f (diff)
downloadYATwm-87b7f6c47d8eab8bfe7f126652a88939aac58a6a.tar.gz
YATwm-87b7f6c47d8eab8bfe7f126652a88939aac58a6a.zip
feat: Added time to log
-rw-r--r--main.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/main.cpp b/main.cpp
index 72ba368..f6cc6e8 100644
--- a/main.cpp
+++ b/main.cpp
@@ -41,8 +41,13 @@ using std::pair;
using std::vector;
std::ofstream yatlog;
+std::time_t timeNow;
+std::tm *now;
+char nowString[80];
-#define log(x) yatlog << x << std::endl
+#define log(x) \
+ updateTime(); \
+ yatlog << nowString << x << std::endl
Display* dpy;
Window root;
@@ -87,6 +92,7 @@ int FFCF(int sID);
void detectScreens();
void focusRoot(int root);
void handleConfigErrs(vector<Err> cfgErrs);
+void updateTime();
void configureRequest(XConfigureRequestEvent e);
void mapRequest(XMapRequestEvent e);
@@ -205,6 +211,12 @@ void handleConfigErrs(vector<Err> cfgErrs)
}
}
}
+void updateTime()
+{
+ timeNow = std::time(0);
+ now = std::localtime(&timeNow);
+ strftime(nowString, sizeof(nowString), "[%H:%M:%S] ", now);
+}
//Keybind commands
const void exit(const CommandArg* argv)
@@ -617,9 +629,13 @@ void mapRequest(XMapRequestEvent e)
XWindowAttributes attr;
XGetWindowAttributes(dpy, e.window, &attr);
if(gotName)
+ {
log("Mapping window: " << name.value);
+ }
else
+ {
log("Mapping window with unknown name (its probably mpv, mpv is annoying)");
+ }
log("\tWindow ID: " << e.window);
Window focusedWindow;
@@ -1036,11 +1052,10 @@ int main(int argc, char** argv)
//Log
yatlog.open(cfg.logFile, std::ios_base::app);
+ yatlog << "\n" << endl;
//Print starting message
- auto timeUnformatted = std::chrono::system_clock::now();
- std::time_t time = std::chrono::system_clock::to_time_t(timeUnformatted);
- log("\nYAT STARTING: " << std::ctime(&time) << "--------------------------------------");
+ log("-------- YATWM STARTING --------");
//Notifications
notify_init("YATwm");