8148219: Add decorator hostname to UL
Reviewed-by: dholmes, mlarsson
This commit is contained in:
parent
6d0ef1b692
commit
a81f4a10da
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -238,14 +238,12 @@ void os::Posix::print_uname_info(outputStream* st) {
|
||||
st->cr();
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
bool os::get_host_name(char* buf, size_t buflen) {
|
||||
struct utsname name;
|
||||
uname(&name);
|
||||
jio_snprintf(buf, buflen, "%s", name.nodename);
|
||||
return true;
|
||||
}
|
||||
#endif // PRODUCT
|
||||
|
||||
bool os::has_allocatable_memory_limit(julong* limit) {
|
||||
struct rlimit rlim;
|
||||
|
@ -1531,12 +1531,10 @@ int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *pa
|
||||
return result;
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
bool os::get_host_name(char* buf, size_t buflen) {
|
||||
DWORD size = (DWORD)buflen;
|
||||
return (GetComputerNameEx(ComputerNameDnsHostname, buf, &size) == TRUE);
|
||||
}
|
||||
#endif // PRODUCT
|
||||
|
||||
void os::get_summary_os_info(char* buf, size_t buflen) {
|
||||
stringStream sst(buf, buflen);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -82,8 +82,7 @@ void LogConfiguration::post_initialize() {
|
||||
|
||||
void LogConfiguration::initialize(jlong vm_start_time) {
|
||||
LogFileOutput::set_file_name_parameters(vm_start_time);
|
||||
LogDecorations::set_vm_start_time_millis(vm_start_time);
|
||||
|
||||
LogDecorations::initialize(vm_start_time);
|
||||
assert(_outputs == NULL, "Should not initialize _outputs before this function, initialize called twice?");
|
||||
_outputs = NEW_C_HEAP_ARRAY(LogOutput*, 2, mtLogging);
|
||||
_outputs[0] = LogOutput::Stdout;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -29,12 +29,21 @@
|
||||
#include "services/management.hpp"
|
||||
|
||||
jlong LogDecorations::_vm_start_time_millis = 0;
|
||||
const char* LogDecorations::_host_name = "";
|
||||
|
||||
LogDecorations::LogDecorations(LogLevelType level, const LogTagSet &tagset, const LogDecorators &decorators)
|
||||
: _level(level), _tagset(tagset), _millis(-1) {
|
||||
create_decorations(decorators);
|
||||
}
|
||||
|
||||
void LogDecorations::initialize(jlong vm_start_time) {
|
||||
char buffer[1024];
|
||||
if (os::get_host_name(buffer, sizeof(buffer))){
|
||||
_host_name = os::strdup_check_oom(buffer);
|
||||
}
|
||||
_vm_start_time_millis = vm_start_time;
|
||||
}
|
||||
|
||||
void LogDecorations::create_decorations(const LogDecorators &decorators) {
|
||||
char* position = _decorations_buffer;
|
||||
#define DECORATOR(full_name, abbr) \
|
||||
@ -109,3 +118,9 @@ char* LogDecorations::create_tags_decoration(char* pos) {
|
||||
int written = _tagset.label(pos, DecorationsBufferSize - (pos - _decorations_buffer));
|
||||
ASSERT_AND_RETURN(written, pos)
|
||||
}
|
||||
|
||||
char* LogDecorations::create_hostname_decoration(char* pos) {
|
||||
int written = jio_snprintf(pos, DecorationsBufferSize - (pos - _decorations_buffer), "%s", _host_name);
|
||||
ASSERT_AND_RETURN(written, pos)
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -39,6 +39,7 @@ class LogDecorations VALUE_OBJ_CLASS_SPEC {
|
||||
LogTagSet _tagset;
|
||||
jlong _millis;
|
||||
static jlong _vm_start_time_millis;
|
||||
static const char* _host_name;
|
||||
|
||||
jlong java_millis();
|
||||
void create_decorations(const LogDecorators& decorators);
|
||||
@ -48,15 +49,13 @@ class LogDecorations VALUE_OBJ_CLASS_SPEC {
|
||||
#undef DECORATOR
|
||||
|
||||
public:
|
||||
static void initialize(jlong vm_start_time);
|
||||
|
||||
LogDecorations(LogLevelType level, const LogTagSet& tagset, const LogDecorators& decorators);
|
||||
|
||||
const char* decoration(LogDecorators::Decorator decorator) const {
|
||||
return _decoration_offset[decorator];
|
||||
}
|
||||
|
||||
static void set_vm_start_time_millis(jlong start_time) {
|
||||
_vm_start_time_millis = start_time;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // SHARE_VM_LOGGING_LOGDECORATIONS_HPP
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -34,6 +34,7 @@
|
||||
// uptimemillis - Milliseconds since the JVM started
|
||||
// timenanos - The same value as generated by System.nanoTime()
|
||||
// uptimenanos - Nanoseconds since the JVM started
|
||||
// hostname - The hostname
|
||||
// pid - The process identifier
|
||||
// tid - The thread identifier
|
||||
// level - The level associated with the log message
|
||||
@ -45,6 +46,7 @@
|
||||
DECORATOR(uptimemillis, um) \
|
||||
DECORATOR(timenanos, tn) \
|
||||
DECORATOR(uptimenanos, un) \
|
||||
DECORATOR(hostname, hn) \
|
||||
DECORATOR(pid, p) \
|
||||
DECORATOR(tid, ti) \
|
||||
DECORATOR(level, l) \
|
||||
|
@ -152,7 +152,6 @@ class os: AllStatic {
|
||||
static size_t page_size_for_region(size_t region_size, size_t min_pages, bool must_be_aligned);
|
||||
|
||||
// Get summary strings for system information in buffer provided
|
||||
static bool get_host_name(char* buf, size_t buflen) PRODUCT_RETURN_(return false;); // true if available
|
||||
static void get_summary_cpu_info(char* buf, size_t buflen);
|
||||
static void get_summary_os_info(char* buf, size_t buflen);
|
||||
|
||||
@ -595,6 +594,9 @@ class os: AllStatic {
|
||||
// Write to stream
|
||||
static int log_vsnprintf(char* buf, size_t len, const char* fmt, va_list args) ATTRIBUTE_PRINTF(3, 0);
|
||||
|
||||
// Get host name in buffer provided
|
||||
static bool get_host_name(char* buf, size_t buflen);
|
||||
|
||||
// Print out system information; they are called by fatal error handler.
|
||||
// Output format may be different on different platforms.
|
||||
static void print_os_info(outputStream* st);
|
||||
|
Loading…
Reference in New Issue
Block a user