author | rehn |
Mon, 04 Apr 2016 15:05:52 +0200 | |
changeset 37247 | bdbfe42632cb |
parent 35230 | a528ea8203ec |
child 37465 | 1d5551f466ee |
permissions | -rw-r--r-- |
33097 | 1 |
/* |
2 |
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. |
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
* |
|
23 |
*/ |
|
24 |
#ifndef SHARE_VM_LOGGING_LOGFILEOUTPUT_HPP |
|
25 |
#define SHARE_VM_LOGGING_LOGFILEOUTPUT_HPP |
|
26 |
||
27 |
#include "logging/logFileStreamOutput.hpp" |
|
35230
a528ea8203ec
8145294: TestLogRotation.java triggers a race in the UL framework
mlarsson
parents:
34637
diff
changeset
|
28 |
#include "runtime/semaphore.hpp" |
33097 | 29 |
#include "utilities/globalDefinitions.hpp" |
30 |
||
31 |
class LogDecorations; |
|
32 |
||
33 |
// The log file output, with support for file rotation based on a target size. |
|
34 |
class LogFileOutput : public LogFileStreamOutput { |
|
35 |
private: |
|
36 |
static const char* FileOpenMode; |
|
37 |
static const char* FileCountOptionKey; |
|
38 |
static const char* FileSizeOptionKey; |
|
39 |
static const char* PidFilenamePlaceholder; |
|
40 |
static const char* TimestampFilenamePlaceholder; |
|
41 |
static const char* TimestampFormat; |
|
42 |
static const size_t StartTimeBufferSize = 20; |
|
43 |
static const size_t PidBufferSize = 21; |
|
44 |
static char _pid_str[PidBufferSize]; |
|
45 |
static char _vm_start_time_str[StartTimeBufferSize]; |
|
46 |
||
47 |
const char* _name; |
|
48 |
char* _file_name; |
|
49 |
char* _archive_name; |
|
50 |
||
51 |
uint _current_file; |
|
52 |
uint _file_count; |
|
53 |
uint _file_count_max_digits; |
|
54 |
||
55 |
size_t _archive_name_len; |
|
56 |
size_t _rotate_size; |
|
57 |
size_t _current_size; |
|
58 |
||
35230
a528ea8203ec
8145294: TestLogRotation.java triggers a race in the UL framework
mlarsson
parents:
34637
diff
changeset
|
59 |
// Semaphore used for synchronizing file rotations and writes |
a528ea8203ec
8145294: TestLogRotation.java triggers a race in the UL framework
mlarsson
parents:
34637
diff
changeset
|
60 |
Semaphore _rotation_semaphore; |
a528ea8203ec
8145294: TestLogRotation.java triggers a race in the UL framework
mlarsson
parents:
34637
diff
changeset
|
61 |
|
33097 | 62 |
void archive(); |
35230
a528ea8203ec
8145294: TestLogRotation.java triggers a race in the UL framework
mlarsson
parents:
34637
diff
changeset
|
63 |
void rotate(); |
33097 | 64 |
bool configure_rotation(const char* options); |
65 |
char *make_file_name(const char* file_name, const char* pid_string, const char* timestamp_string); |
|
66 |
static size_t parse_value(const char* value_str); |
|
67 |
||
35230
a528ea8203ec
8145294: TestLogRotation.java triggers a race in the UL framework
mlarsson
parents:
34637
diff
changeset
|
68 |
bool should_rotate() { |
a528ea8203ec
8145294: TestLogRotation.java triggers a race in the UL framework
mlarsson
parents:
34637
diff
changeset
|
69 |
return _file_count > 0 && _rotate_size > 0 && _current_size >= _rotate_size; |
33097 | 70 |
} |
71 |
||
72 |
public: |
|
73 |
LogFileOutput(const char *name); |
|
74 |
virtual ~LogFileOutput(); |
|
75 |
virtual bool initialize(const char* options); |
|
76 |
virtual int write(const LogDecorations& decorations, const char* msg); |
|
35230
a528ea8203ec
8145294: TestLogRotation.java triggers a race in the UL framework
mlarsson
parents:
34637
diff
changeset
|
77 |
virtual void force_rotate(); |
34637
9b9298044d23
8140556: Add force rotation option to VM.log jcmd
ysuenaga
parents:
33097
diff
changeset
|
78 |
|
33097 | 79 |
virtual const char* name() const { |
80 |
return _name; |
|
81 |
} |
|
82 |
||
83 |
static void set_file_name_parameters(jlong start_time); |
|
84 |
}; |
|
85 |
||
86 |
#endif // SHARE_VM_LOGGING_LOGFILEOUTPUT_HPP |