2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2016 Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
22 #include <folly/futures/Future.h>
23 #include <folly/json/json.h>
24 #include <folly/Range.h>
30 ///////////////////////////////////////////////////////////////////////////////
32 struct StructuredLogEntry
{
35 // Any previous value for the same key is silently overwritten.
36 void setInt(folly::StringPiece key
, int64_t value
);
37 void setStr(folly::StringPiece key
, folly::StringPiece value
);
38 void setSet(folly::StringPiece key
,
39 const std::set
<folly::StringPiece
>& values
);
40 void setVec(folly::StringPiece key
,
41 const std::vector
<folly::StringPiece
>& values
);
42 void setStackTrace(folly::StringPiece key
, const StackTrace
& st
);
44 // Set the given key to a randomly generated UUID stable for this
46 void setProcessUuid(folly::StringPiece key
);
50 bool force_init
{false};
51 folly::dynamic ints
, strs
, sets
, vecs
;
54 std::string
show(const StructuredLogEntry
&);
57 * Interface for recording structured data for relatively infrequent events.
59 namespace StructuredLog
{
60 using LogFn
= void (*)(const std::string
&,
61 const StructuredLogEntry
&);
62 using RecordGlobalsFn
= void (*)(StructuredLogEntry
&);
65 bool coinflip(uint32_t rate
);
66 void enable(LogFn log
, RecordGlobalsFn globals
);
67 void log(const std::string
&, const StructuredLogEntry
&);
68 void recordRequestGlobals(StructuredLogEntry
&);
71 ///////////////////////////////////////////////////////////////////////////////