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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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();
|
st->cr();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef PRODUCT
|
|
||||||
bool os::get_host_name(char* buf, size_t buflen) {
|
bool os::get_host_name(char* buf, size_t buflen) {
|
||||||
struct utsname name;
|
struct utsname name;
|
||||||
uname(&name);
|
uname(&name);
|
||||||
jio_snprintf(buf, buflen, "%s", name.nodename);
|
jio_snprintf(buf, buflen, "%s", name.nodename);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
#endif // PRODUCT
|
|
||||||
|
|
||||||
bool os::has_allocatable_memory_limit(julong* limit) {
|
bool os::has_allocatable_memory_limit(julong* limit) {
|
||||||
struct rlimit rlim;
|
struct rlimit rlim;
|
||||||
|
@ -1531,12 +1531,10 @@ int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *pa
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef PRODUCT
|
|
||||||
bool os::get_host_name(char* buf, size_t buflen) {
|
bool os::get_host_name(char* buf, size_t buflen) {
|
||||||
DWORD size = (DWORD)buflen;
|
DWORD size = (DWORD)buflen;
|
||||||
return (GetComputerNameEx(ComputerNameDnsHostname, buf, &size) == TRUE);
|
return (GetComputerNameEx(ComputerNameDnsHostname, buf, &size) == TRUE);
|
||||||
}
|
}
|
||||||
#endif // PRODUCT
|
|
||||||
|
|
||||||
void os::get_summary_os_info(char* buf, size_t buflen) {
|
void os::get_summary_os_info(char* buf, size_t buflen) {
|
||||||
stringStream sst(buf, 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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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) {
|
void LogConfiguration::initialize(jlong vm_start_time) {
|
||||||
LogFileOutput::set_file_name_parameters(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?");
|
assert(_outputs == NULL, "Should not initialize _outputs before this function, initialize called twice?");
|
||||||
_outputs = NEW_C_HEAP_ARRAY(LogOutput*, 2, mtLogging);
|
_outputs = NEW_C_HEAP_ARRAY(LogOutput*, 2, mtLogging);
|
||||||
_outputs[0] = LogOutput::Stdout;
|
_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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -29,12 +29,21 @@
|
|||||||
#include "services/management.hpp"
|
#include "services/management.hpp"
|
||||||
|
|
||||||
jlong LogDecorations::_vm_start_time_millis = 0;
|
jlong LogDecorations::_vm_start_time_millis = 0;
|
||||||
|
const char* LogDecorations::_host_name = "";
|
||||||
|
|
||||||
LogDecorations::LogDecorations(LogLevelType level, const LogTagSet &tagset, const LogDecorators &decorators)
|
LogDecorations::LogDecorations(LogLevelType level, const LogTagSet &tagset, const LogDecorators &decorators)
|
||||||
: _level(level), _tagset(tagset), _millis(-1) {
|
: _level(level), _tagset(tagset), _millis(-1) {
|
||||||
create_decorations(decorators);
|
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) {
|
void LogDecorations::create_decorations(const LogDecorators &decorators) {
|
||||||
char* position = _decorations_buffer;
|
char* position = _decorations_buffer;
|
||||||
#define DECORATOR(full_name, abbr) \
|
#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));
|
int written = _tagset.label(pos, DecorationsBufferSize - (pos - _decorations_buffer));
|
||||||
ASSERT_AND_RETURN(written, pos)
|
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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* 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;
|
LogTagSet _tagset;
|
||||||
jlong _millis;
|
jlong _millis;
|
||||||
static jlong _vm_start_time_millis;
|
static jlong _vm_start_time_millis;
|
||||||
|
static const char* _host_name;
|
||||||
|
|
||||||
jlong java_millis();
|
jlong java_millis();
|
||||||
void create_decorations(const LogDecorators& decorators);
|
void create_decorations(const LogDecorators& decorators);
|
||||||
@ -48,15 +49,13 @@ class LogDecorations VALUE_OBJ_CLASS_SPEC {
|
|||||||
#undef DECORATOR
|
#undef DECORATOR
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static void initialize(jlong vm_start_time);
|
||||||
|
|
||||||
LogDecorations(LogLevelType level, const LogTagSet& tagset, const LogDecorators& decorators);
|
LogDecorations(LogLevelType level, const LogTagSet& tagset, const LogDecorators& decorators);
|
||||||
|
|
||||||
const char* decoration(LogDecorators::Decorator decorator) const {
|
const char* decoration(LogDecorators::Decorator decorator) const {
|
||||||
return _decoration_offset[decorator];
|
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
|
#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.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -34,6 +34,7 @@
|
|||||||
// uptimemillis - Milliseconds since the JVM started
|
// uptimemillis - Milliseconds since the JVM started
|
||||||
// timenanos - The same value as generated by System.nanoTime()
|
// timenanos - The same value as generated by System.nanoTime()
|
||||||
// uptimenanos - Nanoseconds since the JVM started
|
// uptimenanos - Nanoseconds since the JVM started
|
||||||
|
// hostname - The hostname
|
||||||
// pid - The process identifier
|
// pid - The process identifier
|
||||||
// tid - The thread identifier
|
// tid - The thread identifier
|
||||||
// level - The level associated with the log message
|
// level - The level associated with the log message
|
||||||
@ -45,6 +46,7 @@
|
|||||||
DECORATOR(uptimemillis, um) \
|
DECORATOR(uptimemillis, um) \
|
||||||
DECORATOR(timenanos, tn) \
|
DECORATOR(timenanos, tn) \
|
||||||
DECORATOR(uptimenanos, un) \
|
DECORATOR(uptimenanos, un) \
|
||||||
|
DECORATOR(hostname, hn) \
|
||||||
DECORATOR(pid, p) \
|
DECORATOR(pid, p) \
|
||||||
DECORATOR(tid, ti) \
|
DECORATOR(tid, ti) \
|
||||||
DECORATOR(level, l) \
|
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);
|
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
|
// 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_cpu_info(char* buf, size_t buflen);
|
||||||
static void get_summary_os_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
|
// Write to stream
|
||||||
static int log_vsnprintf(char* buf, size_t len, const char* fmt, va_list args) ATTRIBUTE_PRINTF(3, 0);
|
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.
|
// Print out system information; they are called by fatal error handler.
|
||||||
// Output format may be different on different platforms.
|
// Output format may be different on different platforms.
|
||||||
static void print_os_info(outputStream* st);
|
static void print_os_info(outputStream* st);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user