diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index f3cff18c..4864d70b 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include "mpdpp.h" @@ -352,6 +352,10 @@ int main(int argc, char *argv[]) signal(SIGPIPE, SIG_IGN); + // redirect std::cerr output to ~/.ncmpcpp/error.log file + std::ofstream errorlog((config_dir + "error.log").c_str(), std::ios::app); + std::cerr.rdbuf(errorlog.rdbuf()); + # ifdef HAVE_CURL_CURL_H pthread_attr_t attr_detached; pthread_attr_init(&attr_detached); @@ -3602,6 +3606,7 @@ int main(int argc, char *argv[]) // key mapping end } + errorlog.close(); Mpd->Disconnect(); DestroyScreen(); return 0;