Path: blob/master/src/hotspot/share/logging/logDecorations.hpp
40930 views
/*1* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/23#ifndef SHARE_LOGGING_LOGDECORATIONS_HPP24#define SHARE_LOGGING_LOGDECORATIONS_HPP2526#include "logging/logDecorators.hpp"27#include "logging/logTagSet.hpp"2829class outputStream;3031// LogDecorations keeps resolved values for decorators, as well as the32// printing code to print them. The values are resolved at the log site (in the33// constructor of LogDecorations); the printing happens when the log message is34// printed. That may happen delayed, and the object may be stored for some time,35// in the context of asynchronous logging. Therefore size of this object matters.36class LogDecorations {3738const jlong _millis; // for "time", "utctime", "timemillis"39const jlong _nanos; // for "timenanos"40const double _elapsed_seconds; // for "uptime", "uptimemillis", "uptimenanos"41const intx _tid; // for "tid"42LogLevelType _level; // for "level" (needs to be nonconst)43const LogTagSet& _tagset; // for "tags"44// In debug mode we keep the decorators around for sanity checking when printing45DEBUG_ONLY(const LogDecorators& _decorators;)4647static const char* volatile _host_name;48static const char* host_name();49static const int _pid; // for "pid"5051#define DECORATOR(name, abbr) void print_##name##_decoration(outputStream* st) const;52DECORATOR_LIST53#undef DECORATOR5455public:5657// max size of a single decoration.58static const size_t max_decoration_size = 255;5960LogDecorations(LogLevelType level, const LogTagSet& tagset, const LogDecorators& decorators);6162void set_level(LogLevelType level) {63_level = level;64}6566void print_decoration(LogDecorators::Decorator decorator, outputStream* st) const;67const char* decoration(LogDecorators::Decorator decorator, char* buf, size_t buflen) const;6869};7071#endif // SHARE_LOGGING_LOGDECORATIONS_HPP727374