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 
  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 
  47  public:
  48   LogDiagnosticCommand(outputStream* output, bool heap_allocated);
  49   void execute(DCmdSource source, TRAPS);
  50   static void registerCommand();
  51   static int num_arguments();
  52 
  53   static const char* name() {
  54     return "VM.log";
  55   }
  56 
  57   static const char* description() {
  58     return "Lists, enables, disables or changes a log output configuration.";
  59   }
  60 
  61   // Used by SecurityManager. This DCMD requires ManagementPermission = control.
  62   static const JavaPermission permission() {
  63     JavaPermission p = {"java.lang.management.ManagementPermission", "control", NULL};
  64     return p;
  65   }
  66 };
  67 
  68 #endif // SHARE_VM_LOGGING_LOGDIAGNOSTICCOMMAND_HPP