diff --git a/src/commands/CmdDiagnostics.cpp b/src/commands/CmdDiagnostics.cpp index 42f8ff1e..fe5d5f47 100644 --- a/src/commands/CmdDiagnostics.cpp +++ b/src/commands/CmdDiagnostics.cpp @@ -25,12 +25,105 @@ //////////////////////////////////////////////////////////////////////////////// #include +#include +#include +#include #include +#include + +#ifdef HAVE_COMMIT +#include +#endif //////////////////////////////////////////////////////////////////////////////// -int CmdDiagnostics () +int CmdDiagnostics (Log& log) { - std::cout << "# diagnostics\n"; + std::stringstream out; + out << "\n" + << PACKAGE_STRING + << "\n"; + + out << " Platform: " << osName () + << "\n\n"; + + // Compiler. + out << "Compiler:\n" +#ifdef __VERSION__ + << " Version: " << __VERSION__ << "\n" +#endif + << " Caps:" +#ifdef __STDC__ + << " +stdc" +#endif +#ifdef __STDC_HOSTED__ + << " +stdc_hosted" +#endif +#ifdef __STDC_VERSION__ + << " +" << __STDC_VERSION__ +#endif +#ifdef _POSIX_VERSION + << " +" << _POSIX_VERSION +#endif +#ifdef _POSIX2_C_VERSION + << " +" << _POSIX2_C_VERSION +#endif +#ifdef _ILP32 + << " +ILP32" +#endif +#ifdef _LP64 + << " +LP64" +#endif + << " +c" << 8 * sizeof (char) + << " +i" << 8 * sizeof (int) + << " +l" << 8 * sizeof (long) + << " +vp" << 8 * sizeof (void*) + << " +time_t" << 8 * sizeof (time_t) + << "\n"; + + // Compiler compliance level. + std::string compliance = "non-compliant"; +#ifdef __cplusplus + int level = __cplusplus; + if (level == 199711) + compliance = "C++98/03"; + else if (level == 201103) + compliance = "C++11"; + else + compliance = format (level); +#endif + out << " Compliance: " + << compliance + << "\n\n"; + + out << "Build Features\n" + + // Build date. + << " Built: " << __DATE__ << " " << __TIME__ << "\n" +#ifdef HAVE_COMMIT + << " Commit: " << COMMIT << "\n" +#endif + << " CMake: " << CMAKE_VERSION << "\n"; + + out << " Build type: " +#ifdef CMAKE_BUILD_TYPE + << CMAKE_BUILD_TYPE +#else + << "-" +#endif + << "\n\n"; + + // Config: .taskrc found, readable, writable + out << "Configuration\n"; + + char* env = getenv ("TIMEWARRIORDB"); + out << " TIMEWARRIORDB: " + << (env ? env : "-") + << "\n"; + + out << "\n"; + std::cout << out.str (); + log.write ("info", out.str ()); + return 0; } diff --git a/src/commands/commands.h b/src/commands/commands.h index 98941129..3361b52b 100644 --- a/src/commands/commands.h +++ b/src/commands/commands.h @@ -35,7 +35,7 @@ int CmdConfig (); int CmdContinue (); int CmdDefault (); int CmdDefine (Rules&); -int CmdDiagnostics (); +int CmdDiagnostics (Log&); int CmdExport (); int CmdExtension (); int CmdGaps (); diff --git a/src/init.cpp b/src/init.cpp index edb734ef..db37326f 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -214,7 +214,7 @@ int dispatchCommand ( else if (closeEnough (allCommands[2], args[1], 2)) status = CmdConfig (); else if (closeEnough (allCommands[3], args[1], 2)) status = CmdContinue (); else if (closeEnough (allCommands[4], args[1], 2)) status = CmdDefine (rules); - else if (closeEnough (allCommands[5], args[1], 2)) status = CmdDiagnostics (); + else if (closeEnough (allCommands[5], args[1], 2)) status = CmdDiagnostics (log); else if (closeEnough (allCommands[6], args[1], 2)) status = CmdExport (); else if (closeEnough (allCommands[7], args[1], 2)) status = CmdGaps (); else if (closeEnough (allCommands[8], args[1], 2)) status = CmdImport ();