Skip to content

Commit

Permalink
adjust log levels
Browse files Browse the repository at this point in the history
  • Loading branch information
thestinger committed Sep 25, 2024
1 parent e99243d commit 6ceeeaa
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,3 +126,15 @@ Standard attestation message in the same format as the Auditor app QR code.

Returns space-separated values in plain text: `<subscribeKey> <verifyInterval>`. Additional fields
may be added in the future.

## Logging

Logs are written via stderr for journald. Log guidelines:

emerg: filesystem or database corruption
alert: service fully not functioning
crit: service partially not functioning
error: service side error for a specific request
warning: errors triggered by clients or missing setup for full functionality such as sending alerts
info: regular logging
debug: not used in production
6 changes: 4 additions & 2 deletions src/main/java/app/attestation/server/AlertDispatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import static app.attestation.server.SyslogLevel.CRIT;

class AlertDispatcher implements Runnable {
private static final long WAIT_MS = 15 * 60 * 1000;
private static final int TIMEOUT_MS = 30 * 1000;
Expand All @@ -33,7 +35,7 @@ public void run() {
try {
conn = AttestationServer.open(AttestationServer.ATTESTATION_DATABASE);
} catch (final SQLiteException e) {
logger.log(Level.SEVERE, "database error, cannot set up Maintenance thread", e);
logger.log(CRIT, "database error, cannot set up Maintenance thread", e);
return;
}
final SQLiteStatement selectConfiguration;
Expand Down Expand Up @@ -62,7 +64,7 @@ public void run() {
selectEmails = conn.prepare("SELECT address FROM EmailAddresses WHERE userId = ?");
} catch (final SQLiteException e) {
conn.dispose();
logger.log(Level.SEVERE, "database error, cannot set up Maintenance thread", e);
logger.log(CRIT, "database error, cannot set up Maintenance thread", e);
return;
}

Expand Down
5 changes: 3 additions & 2 deletions src/main/java/app/attestation/server/AttestationServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
import static app.attestation.server.AttestationProtocol.fingerprintsStock;
import static app.attestation.server.AttestationProtocol.fingerprintsStrongBoxCustomOS;
import static app.attestation.server.AttestationProtocol.fingerprintsStrongBoxStock;
import static app.attestation.server.SyslogLevel.ALERT;
import static com.almworks.sqlite4java.SQLiteConstants.SQLITE_CONSTRAINT_UNIQUE;

public class AttestationServer {
Expand Down Expand Up @@ -296,7 +297,7 @@ public static void main(final String[] args) throws Exception {
createSamplesTable(samplesConn);

if (userVersion < 1) {
logger.severe(SAMPLES_DATABASE + " database schemas older than version 1 are no longer " +
logger.log(ALERT, SAMPLES_DATABASE + " database schemas older than version 1 are no longer " +
"supported. Use an older AttestationServer revision to upgrade.");
System.exit(1);
}
Expand All @@ -321,7 +322,7 @@ public static void main(final String[] args) throws Exception {
createAttestationIndices(attestationConn);

if (userVersion < 11) {
logger.severe(ATTESTATION_DATABASE + " database schemas older than version 10 are no longer " +
logger.log(ALERT, ATTESTATION_DATABASE + " database schemas older than version 10 are no longer " +
"supported. Use an older AttestationServer revision to upgrade.");
System.exit(1);
}
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/app/attestation/server/Maintenance.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import java.util.logging.Level;
import java.util.logging.Logger;

import static app.attestation.server.SyslogLevel.CRIT;

class Maintenance implements Runnable {
private static final long WAIT_MS = 24 * 60 * 60 * 1000;
private static final long DELETE_EXPIRY_MS = 7L * 24 * 60 * 60 * 1000;
Expand All @@ -29,7 +31,7 @@ public void run() {
samplesConn = AttestationServer.open(AttestationServer.SAMPLES_DATABASE);
attestationConn = AttestationServer.open(AttestationServer.ATTESTATION_DATABASE);
} catch (final SQLiteException e) {
logger.log(Level.SEVERE, "database error, cannot set up Maintenance thread", e);
logger.log(CRIT, "database error, cannot set up Maintenance thread", e);
return;
}
final SQLiteStatement deleteExpiredSessions;
Expand All @@ -47,7 +49,7 @@ public void run() {
} catch (final SQLiteException e) {
attestationConn.dispose();
samplesConn.dispose();
logger.log(Level.SEVERE, "database error, cannot set up Maintenance thread", e);
logger.log(CRIT, "database error, cannot set up Maintenance thread", e);
return;
}

Expand Down

0 comments on commit 6ceeeaa

Please sign in to comment.