Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for a specific deprecation logging that can be used to turn on in order to notify users of a specific feature, flag, setting, parameter, ... being deprecated. The deprecation logger logs with a "deprecation." prefix logge (or "org.elasticsearch.deprecation." if full name is used), and outputs the logging to a dedicated deprecation log file. Deprecation logging are logged under the DEBUG category. The idea is not to enabled them by default (under WARN or ERROR) when running embedded in another application. By default they are turned off (INFO), in order to turn it on, the "deprecation" category need to be set to DEBUG. This can be set in the logging file or using the cluster update settings API, see the documentation Closes #11033
- Loading branch information
Showing
10 changed files
with
121 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/main/java/org/elasticsearch/common/logging/DeprecationLogger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Licensed to Elasticsearch under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
package org.elasticsearch.common.logging; | ||
|
||
/** | ||
* A logger that logs deprecation notices. | ||
*/ | ||
public class DeprecationLogger { | ||
|
||
private final ESLogger logger; | ||
|
||
/** | ||
* Creates a new deprecation logger based on the parent logger. Automatically | ||
* prefixes the logger name with "deprecation", if it starts with "org.elasticsearch.", | ||
* it replaces "org.elasticsearch" with "org.elasticsearch.deprecation" to maintain | ||
* the "org.elasticsearch" namespace. | ||
*/ | ||
public DeprecationLogger(ESLogger parentLogger) { | ||
String name = parentLogger.getName(); | ||
if (name.startsWith("org.elasticsearch")) { | ||
name = name.replace("org.elasticsearch.", "org.elasticsearch.deprecation."); | ||
} else { | ||
name = "deprecation." + name; | ||
} | ||
this.logger = ESLoggerFactory.getLogger(parentLogger.getPrefix(), name); | ||
} | ||
|
||
/** | ||
* Logs a deprecated message. | ||
*/ | ||
public void deprecated(String msg, Object... params) { | ||
logger.debug(msg, params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters