10#ifndef INCLUDED_COMPHELPER_TRACEEVENT_HXX
11#define INCLUDED_COMPHELPER_TRACEEVENT_HXX
21#include <osl/process.h>
22#include <osl/thread.h>
24#include <com/sun/star/uno/Sequence.h>
26#include <rtl/ustrbuf.hxx>
27#include <rtl/ustring.hxx>
38 oslProcessInfo aProcessInfo;
39 aProcessInfo.Size =
sizeof(oslProcessInfo);
40 if (osl_getProcessInfo(
nullptr, osl_Process_IDENTIFIER, &aProcessInfo)
41 == osl_Process_E_None)
42 return aProcessInfo.Ident;
47 static void (*s_pBufferFullCallback)();
52 static void addRecording(
const OUString& sObject);
57 osl_getSystemTime(&systemTime);
58 return static_cast<long long>(systemTime.Seconds) * 1000000 + systemTime.Nanosec / 1000;
66 OUStringBuffer sResult(
",\"args\":{");
72 sResult.append(
"\"" +
i.first +
"\":\"" +
i.second +
"\"");
77 return sResult.makeStringAndClear();
84 : m_nPid(s_bRecording ? getPid() : 1)
85 , m_sArgs(
std::move(sArgs))
95 static void addInstantEvent(
const char* sName,
const std::map<OUString, OUString>& args
96 = std::map<OUString, OUString>());
98 static void startRecording();
99 static void stopRecording();
100 static void setBufferSizeAndCallback(std::size_t bufferSize,
void (*bufferFullCallback)());
102 static std::vector<OUString> getEventVectorAndClear();
104 static css::uno::Sequence<OUString> getRecordingAndClear();
118 NamedEvent(
const char* sName,
const std::map<OUString, OUString>& aArgs)
136 public std::enable_shared_from_this<AsyncEvent>
142 AsyncEvent(
const char* sName,
int nId,
const std::map<OUString, OUString>& args)
145 , m_bBeginRecorded(false)
150 long long nNow = getNow();
160 + OUString::number(m_nId) + m_sArgs
163 + OUString::number(nNow)
166 + OUString::number(m_nPid)
169 + OUString::number(osl_getThreadIdentifier(
nullptr)) +
"},");
170 m_bBeginRecorded =
true;
175 if (!m_bBeginRecorded)
178 m_bBeginRecorded =
false;
180 long long nNow = getNow();
189 + OUString::number(m_nId) + m_sArgs
192 + OUString::number(nNow)
195 + OUString::number(m_nPid)
198 + OUString::number(osl_getThreadIdentifier(
nullptr)) +
"},");
203 const std::map<OUString, OUString>& args = std::map<OUString, OUString>())
AsyncEvent(const char *sName, const std::map< OUString, OUString > &args=std::map< OUString, OUString >())
AsyncEvent(const char *sName, int nId, const std::map< OUString, OUString > &args)
NamedEvent(const char *sName, const std::map< OUString, OUString > &aArgs)
NamedEvent(const char *sName, const OUString &sArgs)
TraceEvent(OUString sArgs)
static std::size_t s_nBufferSize
static void addRecording(const OUString &sObject)
static std::atomic< bool > s_bRecording
static long long getNow()
TraceEvent(const std::map< OUString, OUString > &aArgs)
static OUString createArgsString(const std::map< OUString, OUString > &args)
#define COMPHELPER_DLLPUBLIC
constexpr OUStringLiteral first