annotate src/share/vm/logging/logDecorations.hpp @ 11208:c84a6ce067ad

8145934: Make ttyLocker equivalent for Unified Logging framework Reviewed-by: rprotacio, stuefe, jrose
author mlarsson
date Mon, 09 May 2016 15:46:12 +0200
parents b0cdcfe42ebf
children a558c122df17
rev   line source
mlarsson@9046 1 /*
mlarsson@10271 2 * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
mlarsson@9046 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
mlarsson@9046 4 *
mlarsson@9046 5 * This code is free software; you can redistribute it and/or modify it
mlarsson@9046 6 * under the terms of the GNU General Public License version 2 only, as
mlarsson@9046 7 * published by the Free Software Foundation.
mlarsson@9046 8 *
mlarsson@9046 9 * This code is distributed in the hope that it will be useful, but WITHOUT
mlarsson@9046 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
mlarsson@9046 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
mlarsson@9046 12 * version 2 for more details (a copy is included in the LICENSE file that
mlarsson@9046 13 * accompanied this code).
mlarsson@9046 14 *
mlarsson@9046 15 * You should have received a copy of the GNU General Public License version
mlarsson@9046 16 * 2 along with this work; if not, write to the Free Software Foundation,
mlarsson@9046 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
mlarsson@9046 18 *
mlarsson@9046 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
mlarsson@9046 20 * or visit www.oracle.com if you need additional information or have any
mlarsson@9046 21 * questions.
mlarsson@9046 22 *
mlarsson@9046 23 */
mlarsson@9046 24 #ifndef SHARE_VM_LOGGING_LOGDECORATIONS_HPP
mlarsson@9046 25 #define SHARE_VM_LOGGING_LOGDECORATIONS_HPP
mlarsson@9046 26
mlarsson@9046 27 #include "logging/logDecorators.hpp"
mlarsson@9046 28 #include "logging/logTagSet.hpp"
mlarsson@9046 29 #include "memory/allocation.hpp"
mlarsson@9046 30
mlarsson@9046 31 // Temporary object containing the necessary data for a log call's decorations (timestamps, etc).
mlarsson@9046 32 class LogDecorations VALUE_OBJ_CLASS_SPEC {
mlarsson@9046 33 public:
mlarsson@9046 34 static const int DecorationsBufferSize = 256;
mlarsson@9046 35 private:
mlarsson@9046 36 char _decorations_buffer[DecorationsBufferSize];
mlarsson@9046 37 char* _decoration_offset[LogDecorators::Count];
mlarsson@9046 38 LogLevelType _level;
mlarsson@9046 39 LogTagSet _tagset;
mlarsson@9046 40 jlong _millis;
mlarsson@9046 41 static jlong _vm_start_time_millis;
mlarsson@10271 42 static const char* _host_name;
mlarsson@9046 43
mlarsson@9046 44 jlong java_millis();
mlarsson@9046 45 void create_decorations(const LogDecorators& decorators);
mlarsson@9046 46
mlarsson@9046 47 #define DECORATOR(name, abbr) char* create_##name##_decoration(char* pos);
mlarsson@9046 48 DECORATOR_LIST
mlarsson@9046 49 #undef DECORATOR
mlarsson@9046 50
mlarsson@9046 51 public:
mlarsson@10271 52 static void initialize(jlong vm_start_time);
mlarsson@10271 53
mlarsson@9046 54 LogDecorations(LogLevelType level, const LogTagSet& tagset, const LogDecorators& decorators);
mlarsson@9046 55
mlarsson@11208 56 LogLevelType level() const {
mlarsson@11208 57 return _level;
mlarsson@11208 58 }
mlarsson@11208 59
mlarsson@11208 60 void set_level(LogLevelType level) {
mlarsson@11208 61 _level = level;
mlarsson@11208 62 }
mlarsson@11208 63
mlarsson@9046 64 const char* decoration(LogDecorators::Decorator decorator) const {
mlarsson@11208 65 if (decorator == LogDecorators::level_decorator) {
mlarsson@11208 66 return LogLevel::name(_level);
mlarsson@11208 67 }
mlarsson@9046 68 return _decoration_offset[decorator];
mlarsson@9046 69 }
mlarsson@9046 70 };
mlarsson@9046 71
mlarsson@9046 72 #endif // SHARE_VM_LOGGING_LOGDECORATIONS_HPP