Optional Two-phase heap tracing
[hiphop-php.git] / hphp / util / cronolog.h
blobb059650f4262c7963beb449619b78e8ab99b527e
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present 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 #ifndef incl_HPHP_CRONOLOG_H_
18 #define incl_HPHP_CRONOLOG_H_
20 #include <atomic>
21 #include <string>
22 #include <cstdio>
23 #include <mutex>
25 #include <folly/portability/Stdlib.h>
27 #include "hphp/util/cronoutils.h"
28 #include "hphp/util/log-file-flusher.h"
30 namespace HPHP {
31 ///////////////////////////////////////////////////////////////////////////////
33 struct Cronolog {
34 Cronolog() = default;
35 Cronolog(const Cronolog&) = delete;
36 Cronolog& operator=(const Cronolog&) = delete;
37 ~Cronolog() {
38 if (m_prevFile) fclose(m_prevFile);
39 if (m_file) fclose(m_file);
41 void setPeriodicity();
42 FILE* getOutputFile();
43 static void changeOwner(const std::string& username,
44 const std::string& symlink);
45 PERIODICITY m_periodicity{UNKNOWN};
46 PERIODICITY m_periodDelayUnits{UNKNOWN};
47 int m_periodMultiple{1};
48 int m_periodDelay{0};
49 int m_useAmericanDateFormats{0};
50 char m_fileName[PATH_MAX];
51 char* m_startTime{nullptr};
52 std::string m_template;
53 std::string m_linkName;
54 char* m_prevLinkName{nullptr};
55 time_t m_timeOffset{0};
56 time_t m_nextPeriod{0};
57 FILE* m_prevFile{nullptr};
58 FILE* m_file{nullptr};
59 LogFileFlusher flusher;
60 std::mutex m_mutex;
63 ///////////////////////////////////////////////////////////////////////////////
66 #endif // incl_HPHP_CRONOLOG_H_