Skip to content

Commit

Permalink
FlatSVGIcon: use log level CONFIG instead of SEVERE and allow dis…
Browse files Browse the repository at this point in the history
…abling logging (issue #823)
  • Loading branch information
DevCharly committed Mar 24, 2024
1 parent 1068884 commit 36e4071
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ FlatLaf Change Log
(issue 809)
- Extras:
- `FlatSVGIcon` color filters now support linear gradients. (PR #817)
- `FlatSVGIcon`: Use log level `CONFIG` instead of `SEVERE` and allow
disabling logging. (issue #823)
- Added support for `JSplitPane.expandableSide` client property to
`FlatSplitPane`.
- Native libraries: Added API version check to test whether native library
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class FlatSVGIcon
extends ImageIcon
implements DisabledIconProvider
{
private static boolean loggingEnabled = true;
private static boolean svgCacheEnabled = true;
// cache that uses soft references for values, which allows freeing SVG documents if no longer used
private static final SoftCache<String, SVGDocument> svgCache = new SoftCache<>();
Expand Down Expand Up @@ -273,7 +274,8 @@ public FlatSVGIcon( InputStream in ) throws IOException {

if( document == null ) {
loadFailed = true;
LoggingFacade.INSTANCE.logSevere( "FlatSVGIcon: failed to load SVG icon from input stream", null );
if( loggingEnabled )
LoggingFacade.INSTANCE.logConfig( "FlatSVGIcon: failed to load SVG icon from input stream", null );
}
}
}
Expand Down Expand Up @@ -477,7 +479,8 @@ private void update() {

if( url == null ) {
loadFailed = true;
LoggingFacade.INSTANCE.logConfig( "FlatSVGIcon: resource '" + name + "' not found (if using Java modules, check whether icon package is opened in module-info.java)", null );
if( loggingEnabled )
LoggingFacade.INSTANCE.logConfig( "FlatSVGIcon: resource '" + name + "' not found (if using Java modules, check whether icon package is opened in module-info.java)", null );
return;
}
}
Expand Down Expand Up @@ -508,7 +511,8 @@ private static SVGDocument loadSVGUncached( URL url ) {
SVGDocument document = svgLoader.load( url );

if( document == null ) {
LoggingFacade.INSTANCE.logSevere( "FlatSVGIcon: failed to load '" + url + "'", null );
if( loggingEnabled )
LoggingFacade.INSTANCE.logConfig( "FlatSVGIcon: failed to load '" + url + "'", null );
return null;
}

Expand Down Expand Up @@ -707,6 +711,16 @@ private static void lafChanged() {
darkLaf = FlatLaf.isLafDark();
}

/** @since 3.4.1 */
public static boolean isLoggingEnabled() {
return loggingEnabled;
}

/** @since 3.4.1 */
public static void setLoggingEnabled( boolean loggingEnabled ) {
FlatSVGIcon.loggingEnabled = loggingEnabled;
}

/** @since 3.4.1 */
public static boolean isSVGDocumentEnabled() {
return svgCacheEnabled;
Expand Down

0 comments on commit 36e4071

Please sign in to comment.