hotspot/src/share/vm/logging/logConfiguration.hpp
changeset 37108 fe800ec86077
parent 35230 a528ea8203ec
child 37994 1a816b464178
equal deleted inserted replaced
37105:e66ce2ddedf8 37108:fe800ec86077
     1 /*
     1 /*
     2  * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
    35 // Global configuration of logging. Handles parsing and configuration of the logging framework,
    35 // Global configuration of logging. Handles parsing and configuration of the logging framework,
    36 // and manages the list of configured log outputs. The actual tag and level configuration is
    36 // and manages the list of configured log outputs. The actual tag and level configuration is
    37 // kept implicitly in the LogTagSets and their LogOutputLists. During configuration the tagsets
    37 // kept implicitly in the LogTagSets and their LogOutputLists. During configuration the tagsets
    38 // are iterated over and updated accordingly.
    38 // are iterated over and updated accordingly.
    39 class LogConfiguration : public AllStatic {
    39 class LogConfiguration : public AllStatic {
       
    40  public:
       
    41   // Function for listeners
       
    42   typedef void (*UpdateListenerFunction)(void);
       
    43 
       
    44   // Register callback for config change.
       
    45   // The callback is always called with ConfigurationLock held,
       
    46   // hence doing log reconfiguration from the callback will deadlock.
       
    47   // The main Java thread may call this callback if there is an early registration
       
    48   // else the attach listener JavaThread, started via diagnostic command, will be executing thread.
       
    49   // The main purpose of this callback is to see if a loglevel have been changed.
       
    50   // There is no way to unregister.
       
    51   static void register_update_listener(UpdateListenerFunction cb);
       
    52 
    40  private:
    53  private:
    41   static LogOutput**  _outputs;
    54   static LogOutput**  _outputs;
    42   static size_t       _n_outputs;
    55   static size_t       _n_outputs;
       
    56 
       
    57   static UpdateListenerFunction*    _listener_callbacks;
       
    58   static size_t                     _n_listener_callbacks;
    43 
    59 
    44   // Create a new output. Returns NULL if failed.
    60   // Create a new output. Returns NULL if failed.
    45   static LogOutput* new_output(char* name, const char* options, outputStream* errstream);
    61   static LogOutput* new_output(char* name, const char* options, outputStream* errstream);
    46 
    62 
    47   // Add an output to the list of configured outputs. Returns the assigned index.
    63   // Add an output to the list of configured outputs. Returns the assigned index.
    57   // Get output index by name. Returns SIZE_MAX if output not found.
    73   // Get output index by name. Returns SIZE_MAX if output not found.
    58   static size_t find_output(const char* name);
    74   static size_t find_output(const char* name);
    59 
    75 
    60   // Configure output (add or update existing configuration) to log on tag-level combination using specified decorators.
    76   // Configure output (add or update existing configuration) to log on tag-level combination using specified decorators.
    61   static void configure_output(size_t idx, const LogTagLevelExpression& tag_level_expression, const LogDecorators& decorators);
    77   static void configure_output(size_t idx, const LogTagLevelExpression& tag_level_expression, const LogDecorators& decorators);
       
    78 
       
    79   // This should be called after any configuration change while still holding ConfigurationLock
       
    80   static void notify_update_listeners();
    62 
    81 
    63  public:
    82  public:
    64   // Initialization and finalization of log configuration, to be run at vm startup and shutdown respectively.
    83   // Initialization and finalization of log configuration, to be run at vm startup and shutdown respectively.
    65   static void initialize(jlong vm_start_time);
    84   static void initialize(jlong vm_start_time);
    66   static void finalize();
    85   static void finalize();