Path: blob/master/src/hotspot/share/logging/logOutput.hpp
40930 views
/*1* Copyright (c) 2015, 2019, 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_LOGOUTPUT_HPP24#define SHARE_LOGGING_LOGOUTPUT_HPP2526#include "logging/logDecorators.hpp"27#include "logging/logLevel.hpp"28#include "logging/logMessageBuffer.hpp"29#include "memory/allocation.hpp"30#include "utilities/globalDefinitions.hpp"3132class LogDecorations;33class LogMessageBuffer;34class LogSelection;35class LogTagSet;3637// The base class/interface for log outputs.38// Keeps track of the latest configuration string,39// and its selected decorators.40class LogOutput : public CHeapObj<mtLogging> {41// Make LogConfiguration a friend to allow it to modify the configuration string.42friend class LogConfiguration;4344private:45static const size_t InitialConfigBufferSize = 256;4647// Track if the output has been reconfigured dynamically during runtime.48// The status is set each time the configuration of the output is modified,49// and is reset once after logging initialization is complete.50bool _reconfigured;5152char* _config_string;53size_t _config_string_buffer_size;5455// Adds the log selection to the config description (e.g. "tag1+tag2*=level").56void add_to_config_string(const LogSelection& selection);5758protected:59LogDecorators _decorators;6061// Replaces the current config description with the given string.62void set_config_string(const char* string);6364// Update the config string for this output to reflect its current configuration65void update_config_string(const size_t on_level[LogLevel::Count]);6667public:68void set_decorators(const LogDecorators &decorators) {69_decorators = decorators;70}7172const LogDecorators& decorators() const {73return _decorators;74}7576bool is_reconfigured() const {77return _reconfigured;78}7980const char* config_string() const {81return _config_string;82}8384LogOutput() : _reconfigured(false), _config_string(NULL), _config_string_buffer_size(0) {85}8687virtual ~LogOutput();8889// If the output can be rotated, trigger a forced rotation, otherwise do nothing.90// Log outputs with rotation capabilities should override this.91virtual void force_rotate() {92// Do nothing by default.93}9495virtual void describe(outputStream *out);9697virtual const char* name() const = 0;98virtual bool initialize(const char* options, outputStream* errstream) = 0;99virtual int write(const LogDecorations& decorations, const char* msg) = 0;100virtual int write(LogMessageBuffer::Iterator msg_iterator) = 0;101};102103#endif // SHARE_LOGGING_LOGOUTPUT_HPP104105106