Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BraillePlot
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Georg Graßnick
BraillePlot
Commits
b899f6c6
Commit
b899f6c6
authored
5 years ago
by
Georg Graßnick
Browse files
Options
Downloads
Patches
Plain Diff
Add logging functionality
parent
80e6799b
No related branches found
No related tags found
1 merge request
!5
Add logging functionality
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
build.gradle
+4
-0
4 additions, 0 deletions
build.gradle
src/main/java/de/tudresden/inf/mci/brailleplot/App.java
+13
-3
13 additions, 3 deletions
src/main/java/de/tudresden/inf/mci/brailleplot/App.java
with
17 additions
and
3 deletions
build.gradle
+
4
−
0
View file @
b899f6c6
...
...
@@ -29,6 +29,10 @@ repositories {
dependencies
{
// Use JUnit test framework
testImplementation
(
'org.junit.jupiter:junit-jupiter:5.4.2'
)
// Logging
compile
group:
'org.slf4j'
,
name:
'slf4j-api'
,
version:
'1.7.26'
compile
group:
'ch.qos.logback'
,
name:
'logback-classic'
,
version:
'1.2.3'
}
test
{
...
...
This diff is collapsed.
Click to expand it.
src/main/java/de/tudresden/inf/mci/brailleplot/App.java
+
13
−
3
View file @
b899f6c6
package
de.tudresden.inf.mci.brailleplot
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
java.util.concurrent.ConcurrentLinkedDeque
;
/**
...
...
@@ -23,11 +26,14 @@ public final class App {
private
static
final
int
EXIT_SUCCESS
=
0
;
private
static
final
int
EXIT_ERROR
=
1
;
private
final
Logger
mLogger
;
private
ConcurrentLinkedDeque
<
Runnable
>
mFinalizers
;
private
App
()
{
sInstance
=
this
;
mFinalizers
=
new
ConcurrentLinkedDeque
<>();
mLogger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
}
/**
...
...
@@ -75,9 +81,9 @@ public final class App {
*/
public
static
void
terminateWithException
(
final
Exception
e
,
final
String
message
)
{
if
(!
message
.
isEmpty
())
{
System
.
err
.
println
(
message
);
getInstance
().
mLogger
.
error
(
message
);
}
e
.
printStackTrace
(
);
getInstance
().
mLogger
.
error
(
"Application will now shut down due to an unrecoverable error"
,
e
);
getInstance
().
runFinalizers
();
System
.
exit
(
EXIT_ERROR
);
}
...
...
@@ -89,11 +95,15 @@ public final class App {
*/
int
run
(
final
String
[]
args
)
{
// Has to be the first finalizer to be added, so that it is run last
registerFinalizer
(()
->
{
System
.
out
.
println
(
"Application terminated
.
"
);
mLogger
.
info
(
"Application terminated"
);
});
try
{
// Logging example
mLogger
.
info
(
"Application started"
);
// Parse command line parameters
...
...
This diff is collapsed.
Click to expand it.
Georg Graßnick
@s9444737--tu-dresden.de
mentioned in issue
#12 (closed)
·
5 years ago
mentioned in issue
#12 (closed)
mentioned in issue #12
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment