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