mirror of
https://github.com/google/nomulus.git
synced 2025-05-12 22:38:16 +02:00
mv com/google/domain/registry google/registry
This change renames directories in preparation for the great package rename. The repository is now in a broken state because the code itself hasn't been updated. However this should ensure that git correctly preserves history for each file.
This commit is contained in:
parent
a41677aea1
commit
5012893c1d
2396 changed files with 0 additions and 0 deletions
78
java/google/registry/tools/LoggingParameters.java
Normal file
78
java/google/registry/tools/LoggingParameters.java
Normal file
|
@ -0,0 +1,78 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed 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 com.google.domain.registry.tools;
|
||||
|
||||
import static com.google.domain.registry.util.ResourceUtils.readResourceBytes;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.domain.registry.tools.params.PathParameter;
|
||||
|
||||
import com.beust.jcommander.Parameter;
|
||||
import com.beust.jcommander.Parameters;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogManager;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/** Parameter delegate class to handle logging configuration for {@link RegistryCli}. */
|
||||
@Parameters(separators = " =")
|
||||
final class LoggingParameters {
|
||||
|
||||
@Nullable
|
||||
@Parameter(
|
||||
names = "--log_level",
|
||||
description = "Default level at which to log messages")
|
||||
private Level logLevel;
|
||||
|
||||
@Parameter(
|
||||
names = "--logging_configs",
|
||||
description = "Comma-delimited list of logging properties to add to the logging.properties "
|
||||
+ "file, e.g. com.example.level=WARNING,com.example.FooClass.level=SEVERE")
|
||||
private List<String> configLines = new ArrayList<>();
|
||||
|
||||
@Nullable
|
||||
@Parameter(
|
||||
names = "--logging_properties_file",
|
||||
description = "File from which to read custom logging properties",
|
||||
validateWith = PathParameter.InputFile.class)
|
||||
private Path configFile;
|
||||
|
||||
private static final ByteSource DEFAULT_LOG_CONFIG =
|
||||
readResourceBytes(LoggingParameters.class, "logging.properties");
|
||||
|
||||
void configureLogging() throws IOException {
|
||||
ByteSource baseConfig = (configFile != null)
|
||||
? Files.asByteSource(configFile.toFile())
|
||||
: DEFAULT_LOG_CONFIG;
|
||||
if (logLevel != null) {
|
||||
configLines.add(".level = " + logLevel);
|
||||
}
|
||||
// Add an extra leading newline in case base properties file does not end in a newline.
|
||||
String customProperties = "\n" + Joiner.on('\n').join(configLines);
|
||||
ByteSource logConfig =
|
||||
ByteSource.concat(baseConfig, ByteSource.wrap(customProperties.getBytes()));
|
||||
try (InputStream input = logConfig.openStream()) {
|
||||
LogManager.getLogManager().readConfiguration(input);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue