1 /* 2 * Copyright (c) 2015, 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 #ifndef SHARE_VM_LOGGING_LOGDIAGNOSTICCOMMAND_HPP_ 25 #define SHARE_VM_LOGGING_LOGDIAGNOSTICCOMMAND_HPP_ 26 #include "services/diagnosticCommand.hpp" 27 28 // The LogDiagnosticCommand represents the 'VM.log' DCMD 29 // that allows configuration of the logging at runtime. 30 // It can be used to view or modify the current log configuration. 31 // VM.log without additional arguments prints the usage description. 32 // The 'list' argument will list all available log tags, 33 // levels, decorators and currently configured log outputs. 34 // Specifying 'disable' will disable logging completely. 35 // The remaining arguments are used to set a log output to log everything 36 // with the specified tags and levels using the given decorators. 37 class LogDiagnosticCommand : public DCmdWithParser { 38 protected: 39 DCmdArgument<char *> _output; 40 DCmdArgument<char *> _output_options; 41 DCmdArgument<char *> _what; 42 DCmdArgument<char *> _decorators; 43 DCmdArgument<bool> _disable; 44 DCmdArgument<bool> _list; 45 46 public: 47 LogDiagnosticCommand(outputStream* output, bool heap_allocated); 48 void execute(DCmdSource source, TRAPS); 49 static void registerCommand(); 50 static int num_arguments(); 51 52 static const char* name() { 53 return "VM.log"; 54 } 55 56 static const char* description() { 57 return "Lists, enables, disables or changes a log output configuration."; 58 } 59 60 // Used by SecurityManager. This DCMD requires ManagementPermission = control. 61 static const JavaPermission permission() { 62 JavaPermission p = {"java.lang.management.ManagementPermission", "control", NULL}; 63 return p; 64 } 65 }; 66 67 #endif