1 /* 2 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 * 23 */ 24 25 #include "precompiled.hpp" 26 #include "jfr/jni/jfrJavaSupport.hpp" 27 #include "jfr/utilities/jfrJavaLog.hpp" 28 #include "jfr/utilities/jfrLog.hpp" 29 30 void JfrJavaLog::subscribe_log_level(jobject log_tag, jint id, TRAPS) { 31 // jdk8 doesn't support log level, so do nothing 32 } 33 34 void JfrJavaLog::log(jint tag_set, jint level, jstring message, TRAPS) { 35 DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD)); 36 if (message == NULL) { 37 return; 38 } 39 ResourceMark rm(THREAD); 40 const char* const s = JfrJavaSupport::c_str(message, CHECK); 41 assert(s != NULL, "invariant"); 42 43 switch(level) { 44 case LogLevel::Off: 45 break; 46 case LogLevel::Trace: 47 log_trace(jfr)(s); 48 break; 49 case LogLevel::Debug: 50 log_debug(jfr)(s); 51 break; 52 case LogLevel::Info: 53 log_info(jfr)(s); 54 break; 55 case LogLevel::Warning: 56 log_warning(jfr)(s); 57 break; 58 case LogLevel::Error: 59 log_error(jfr)(s); 60 break; 61 default: 62 break; 63 } 64 }