Skip to content

Commit cb0572d

Browse files
authored
Merge pull request #1 from SentryMan/main
Default to System Logger on Error
2 parents 97bebe4 + 10ccb0d commit cb0572d

File tree

6 files changed

+79
-12
lines changed

6 files changed

+79
-12
lines changed

.github/dependabot.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "maven"
4+
directory: "/"
5+
schedule:
6+
interval: weekly
7+
open-pull-requests-limit: 10
8+
groups:
9+
dependencies:
10+
patterns:
11+
- "*"
12+
labels:
13+
- "dependencies"
14+
target-branch: "master"
15+
16+
- package-ecosystem: "github-actions"
17+
directory: "/"
18+
schedule:
19+
interval: "weekly"
20+
open-pull-requests-limit: 5
21+
commit-message:
22+
prefix: "[workflow]"
23+
labels:
24+
- "dependencies"
25+
target-branch: "master"
26+
groups:
27+
dependencies:
28+
patterns:
29+
- "*"

.github/workflows/build.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ on: [push, pull_request]
55

66
jobs:
77
build:
8-
98
runs-on: ${{ matrix.os }}
109
permissions:
1110
contents: read
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Dependabot auto-merge
2+
on: pull_request
3+
4+
permissions:
5+
contents: write
6+
pull-requests: write
7+
8+
jobs:
9+
dependabot:
10+
runs-on: ubuntu-latest
11+
if: ${{ github.actor == 'dependabot[bot]' }}
12+
steps:
13+
- name: Dependabot metadata
14+
id: metadata
15+
uses: dependabot/fetch-metadata@v2
16+
with:
17+
github-token: "${{ secrets.GITHUB_TOKEN }}"
18+
- name: Approve a PR
19+
run: gh pr review --approve "$PR_URL"
20+
env:
21+
PR_URL: ${{github.event.pull_request.html_url}}
22+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
23+
# Enable for automerge
24+
- name: Enable auto-merge for Dependabot PRs
25+
run: gh pr merge --auto --merge "$PR_URL"
26+
env:
27+
PR_URL: ${{github.event.pull_request.html_url}}
28+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
.idea/
22
*.iml
33
target/
4-
4+
build/
5+
.gradle
6+
*.prefs
7+
*.class*
8+
*.factorypath
9+
*.project
10+
*.processors
11+
*/bin/

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
<properties>
2020
<surefire.useModulePath>false</surefire.useModulePath>
21+
<project.build.outputTimestamp>2025-02-26T05:43:52Z</project.build.outputTimestamp>
2122
</properties>
2223

2324
<dependencies>
@@ -27,7 +28,6 @@
2728
<version>1.1</version>
2829
<scope>test</scope>
2930
</dependency>
30-
3131
</dependencies>
3232

3333
</project>

src/main/java/io/avaje/applog/AppLog.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.avaje.applog;
22

3+
import java.lang.System.Logger.Level;
34
import java.util.ResourceBundle;
5+
import java.util.ServiceConfigurationError;
46
import java.util.ServiceLoader;
57

68
/**
@@ -24,8 +26,6 @@
2426
* {@link AppLog.Provider} to provide System.Logger implementations returned by AppLog.
2527
* The reason to use AppLog is that it provides this 1 extra level of indirection that
2628
* gives applications control over the System.Logger implementation returned by AppLog.
27-
*
28-
*
2929
* <hr/>
3030
*
3131
* <h2>Main differences to slf4j-api</h2>
@@ -77,14 +77,18 @@
7777
*/
7878
public final class AppLog {
7979

80-
private static final Provider provider = ServiceLoader.load(Provider.class)
81-
.findFirst()
82-
.orElseGet(DefaultProvider::new);
80+
private static final Provider provider = loadProvider();
8381

84-
/**
85-
* Not accessible.
86-
*/
87-
private AppLog() {
82+
private AppLog() {}
83+
84+
private static Provider loadProvider() {
85+
try {
86+
return ServiceLoader.load(Provider.class).findFirst().orElseGet(DefaultProvider::new);
87+
} catch (ServiceConfigurationError e) {
88+
getLogger(AppLog.class.getCanonicalName())
89+
.log(Level.ERROR, "Failed to Service Load AppLog Provider, using System.Logger implementation", e);
90+
return new DefaultProvider();
91+
}
8892
}
8993

9094
/**

0 commit comments

Comments
 (0)