-
Notifications
You must be signed in to change notification settings - Fork 565
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix warning message; add test (#9631)
* Fix warning message; add test to check that the correct property name is mentioned in the message * Renove commented code from test
- Loading branch information
Showing
5 changed files
with
116 additions
and
5 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
50 changes: 50 additions & 0 deletions
50
microprofile/telemetry/src/test/java/io/helidon/microprofile/telemetry/MemoryLogHandler.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,50 @@ | ||
/* | ||
* Copyright (c) 2025 Oracle and/or its affiliates. | ||
* | ||
* 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 io.helidon.microprofile.telemetry; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.io.UnsupportedEncodingException; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.logging.LogRecord; | ||
import java.util.logging.StreamHandler; | ||
|
||
public class MemoryLogHandler extends StreamHandler { | ||
|
||
private final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); | ||
|
||
private static MemoryLogHandler create() { | ||
try { | ||
return new MemoryLogHandler(); | ||
} catch (UnsupportedEncodingException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public MemoryLogHandler() throws UnsupportedEncodingException { | ||
setOutputStream(outputStream); | ||
setEncoding(StandardCharsets.UTF_8.name()); | ||
} | ||
|
||
@Override | ||
public synchronized void publish(LogRecord record) { | ||
super.publish(record); | ||
flush(); // forces flush on writer | ||
} | ||
|
||
public String logAsString() { | ||
return outputStream.toString(StandardCharsets.UTF_8); | ||
} | ||
} |
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
27 changes: 27 additions & 0 deletions
27
microprofile/telemetry/src/test/resources/logging-test.properties
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,27 @@ | ||
# | ||
# Copyright (c) 2025 Oracle and/or its affiliates. | ||
# | ||
# 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. | ||
# | ||
handlers=java.util.logging.ConsoleHandler | ||
java.util.logging.ConsoleHandler.level=FINEST | ||
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter | ||
java.util.logging.SimpleFormatter.format=%1$tH:%1$tM:%1$tS %4$s %3$s %5$s%6$s%n | ||
# Global logging level. Can be overridden by specific loggers | ||
.level=INFO | ||
|
||
io.helidon.microprofile.telemetry.MemoryLogHandler.level=INFO | ||
io.helidon.microprofile.telemetry.MemoryLogHandler.append=false | ||
io.helidon.microprofile.telemetry.HelidonTelemetryContainerFilter.level=INFO | ||
io.helidon.microprofile.telemetry.HelidonTelemetryContainerFilter.useParentHandlers=false | ||
io.helidon.microprofile.telemetry.HelidonTelemetryContainerFilter.handlers=io.helidon.microprofile.telemetry.MemoryLogHandler |