summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAybuke Ozdemir <aybuke.147@gmail.com>2015-12-05 16:19:56 +0200
committerjan iversen <jani@documentfoundation.org>2016-01-10 12:23:04 +0000
commitd61c16966b017abdbebf5ec0c2131de5a91c67f8 (patch)
treeeda2641c08a2e7c5214b66cb733bd23c5ba5f3e0
parent536d0e27f05d9db7469bd8a3571c87b2ea885367 (diff)
tdf#95505 Dump usage stats to text file
1de031c94b2ef9c4ae45a8906b250a95d3c47c47 Change-Id: I1de031c94b2ef9c4ae45a8906b250a95d3c47c47 Reviewed-on: https://gerrit.libreoffice.org/20413 Reviewed-by: jan iversen <jani@documentfoundation.org> Tested-by: jan iversen <jani@documentfoundation.org> Tested-by: Jenkins <ci@libreoffice.org>
-rw-r--r--sfx2/source/control/unoctitm.cxx30
1 files changed, 25 insertions, 5 deletions
diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx
index 864582603f90..1a8290638aae 100644
--- a/sfx2/source/control/unoctitm.cxx
+++ b/sfx2/source/control/unoctitm.cxx
@@ -65,6 +65,9 @@
#include "statcach.hxx"
#include <sfx2/msgpool.hxx>
#include <sfx2/objsh.hxx>
+#include <osl/file.hxx>
+#include <rtl/ustring.hxx>
+#include <unotools/pathoptions.hxx>
#include <iostream>
#include <map>
@@ -74,6 +77,8 @@
#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;
@@ -640,13 +645,28 @@ void UsageInfo::save()
if (!mbIsCollecting)
return;
- // TODO - do a real saving here, not only dump to the screen
- std::cerr << "Usage information:" << std::endl;
- for (UsageMap::const_iterator it = maUsage.begin(); it != maUsage.end(); ++it)
+ const OUString path(USAGE);
+ osl::File file(path);
+
+ if( file.open(osl_File_OpenFlag_Read | osl_File_OpenFlag_Write | osl_File_OpenFlag_Create) == osl::File::E_None )
{
- std::cerr << it->first << ';' << it->second << std::endl;
+ OString jan = "Usage information:\n";
+
+ for (UsageMap::const_iterator it = maUsage.begin(); it != maUsage.end(); ++it)
+ jan += "\n" + it->first.toUtf8() + ";" + OString::number(it->second);
+
+ jan += "\nUsage information end\n";
+ sal_uInt64 written = 0;
+ file.write(jan.pData->buffer, jan.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;
}
- std::cerr << "Usage information end" << std::endl;
}
class theUsageInfo : public rtl::Static<UsageInfo, theUsageInfo> {};