Add a HHIR-level peephole optimization to reorder CheckTypes
[hiphop-php.git] / hphp / util / struct-log.h
blob001d128055db882f5261b4a96c14aef700a5cc4e
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
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 +----------------------------------------------------------------------+
17 #pragma once
19 #include <set>
20 #include <string>
21 #include <vector>
22 #include <folly/futures/Future.h>
23 #include <folly/json.h>
24 #include <folly/Range.h>
26 namespace HPHP {
28 struct StackTrace;
30 ///////////////////////////////////////////////////////////////////////////////
32 struct StructuredLogEntry {
33 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);
43 void clear();
45 bool force_init{false};
46 folly::dynamic ints, strs, sets, vecs;
49 std::string show(const StructuredLogEntry&);
52 * Interface for recording structured data for relatively infrequent events.
54 namespace StructuredLog {
55 using LogFn = void (*)(const std::string&,
56 const StructuredLogEntry&);
57 using RecordGlobalsFn = void (*)(StructuredLogEntry&);
59 bool enabled();
60 bool coinflip(uint32_t rate);
61 void enable(LogFn log, RecordGlobalsFn globals);
62 void log(const std::string&, const StructuredLogEntry&);
63 void recordRequestGlobals(StructuredLogEntry&);
66 ///////////////////////////////////////////////////////////////////////////////