sfx2/source/control/unoctitm.cxx | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-)
New commits: commit 3563d8dde1068094a7b79aad4aa864301583006d Author: aybuke <aybuke....@gmail.com> Date: Tue Jan 19 17:28:30 2016 +0200 tdf#95505 Dump usage stats to text file in user profile. Change-Id: I12c44db6f03c789682688d39aafb650d074c63f5 Reviewed-on: https://gerrit.libreoffice.org/21609 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: jan iversen <j...@documentfoundation.org> diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 6e63bc7..78bd160 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -68,6 +68,7 @@ #include <osl/file.hxx> #include <rtl/ustring.hxx> #include <unotools/pathoptions.hxx> +#include <osl/time.h> #include <iostream> #include <map> @@ -77,8 +78,6 @@ #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <comphelper/lok.hxx> -#define USAGE "file:///~/.config/libreofficedev/4/user/usage.txt" - using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::util; @@ -645,28 +644,38 @@ void UsageInfo::save() if (!mbIsCollecting) return; - const OUString path(USAGE); + OUString path(SvtPathOptions().GetConfigPath()); + path += "usage/"; + osl::Directory::createPath(path); + + //get system time information. + TimeValue systemTime; + TimeValue localTime; + oslDateTime localDateTime; + osl_getSystemTime( &systemTime ); + osl_getLocalTimeFromSystemTime( &systemTime, &localTime ); + osl_getDateTimeFromTimeValue( &localTime, &localDateTime ); + + sal_Char time[1024]; + sprintf(time,"%4i-%02i-%02iT%02i_%02i_%02i", localDateTime.Year, localDateTime.Month, localDateTime.Day, localDateTime.Hours, localDateTime.Minutes, localDateTime.Seconds); + + //filename type: usage-YYYY-MM-DDTHH_MM_SS.csv + OUString filename = "usage-" + OUString::createFromAscii(time) + ".csv"; + path += filename; + osl::File file(path); if( file.open(osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create) == osl::File::E_None ) { - OString aUsageInfoMsg = "Usage information:\n"; + OString aUsageInfoMsg = "Document Type,Command,Count"; for (UsageMap::const_iterator it = maUsage.begin(); it != maUsage.end(); ++it) aUsageInfoMsg += "\n" + it->first.toUtf8() + ";" + OString::number(it->second); - aUsageInfoMsg += "\nUsage information end\n"; sal_uInt64 written = 0; file.write(aUsageInfoMsg.pData->buffer, aUsageInfoMsg.getLength(), written); file.close(); } - - else{ - std::cerr << "Usage information:" << std::endl; - for (UsageMap::const_iterator it = maUsage.begin(); it != maUsage.end(); ++it) - std::cerr << it->first << ';' << it->second << std::endl; - std::cerr << "Usage information end" << std::endl; - } } class theUsageInfo : public rtl::Static<UsageInfo, theUsageInfo> {}; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits