Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/hotspot/share/logging/logDecorations.hpp
40930 views
1
/*
2
* Copyright (c) 2015, 2020, 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_LOGGING_LOGDECORATIONS_HPP
25
#define SHARE_LOGGING_LOGDECORATIONS_HPP
26
27
#include "logging/logDecorators.hpp"
28
#include "logging/logTagSet.hpp"
29
30
class outputStream;
31
32
// LogDecorations keeps resolved values for decorators, as well as the
33
// printing code to print them. The values are resolved at the log site (in the
34
// constructor of LogDecorations); the printing happens when the log message is
35
// printed. That may happen delayed, and the object may be stored for some time,
36
// in the context of asynchronous logging. Therefore size of this object matters.
37
class LogDecorations {
38
39
const jlong _millis; // for "time", "utctime", "timemillis"
40
const jlong _nanos; // for "timenanos"
41
const double _elapsed_seconds; // for "uptime", "uptimemillis", "uptimenanos"
42
const intx _tid; // for "tid"
43
LogLevelType _level; // for "level" (needs to be nonconst)
44
const LogTagSet& _tagset; // for "tags"
45
// In debug mode we keep the decorators around for sanity checking when printing
46
DEBUG_ONLY(const LogDecorators& _decorators;)
47
48
static const char* volatile _host_name;
49
static const char* host_name();
50
static const int _pid; // for "pid"
51
52
#define DECORATOR(name, abbr) void print_##name##_decoration(outputStream* st) const;
53
DECORATOR_LIST
54
#undef DECORATOR
55
56
public:
57
58
// max size of a single decoration.
59
static const size_t max_decoration_size = 255;
60
61
LogDecorations(LogLevelType level, const LogTagSet& tagset, const LogDecorators& decorators);
62
63
void set_level(LogLevelType level) {
64
_level = level;
65
}
66
67
void print_decoration(LogDecorators::Decorator decorator, outputStream* st) const;
68
const char* decoration(LogDecorators::Decorator decorator, char* buf, size_t buflen) const;
69
70
};
71
72
#endif // SHARE_LOGGING_LOGDECORATIONS_HPP
73
74