-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Thomas Børlum
committed
Apr 11, 2011
1 parent
e9258a2
commit 49388e9
Showing
12 changed files
with
131 additions
and
24 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
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
19 changes: 19 additions & 0 deletions
19
...jects/replication/src/main/java/com/trifork/stamdata/replication/logging/AuditLogger.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,19 @@ | ||
package com.trifork.stamdata.replication.logging; | ||
|
||
/** | ||
* An abstract for different kinds of audit loggers. | ||
* | ||
* Uses the Strategy Pattern. | ||
* | ||
* @author Thomas Børlum (thb@trifork.com) | ||
*/ | ||
public interface AuditLogger { | ||
|
||
/** | ||
* Logs a message formed by the format and arguments. | ||
* | ||
* @param format The format of the message. | ||
* @param args The arguments to be inserted into the format. | ||
*/ | ||
void log(String format, Object...args); | ||
} |
31 changes: 31 additions & 0 deletions
31
...lication/src/main/java/com/trifork/stamdata/replication/logging/CompositeAuditLogger.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,31 @@ | ||
package com.trifork.stamdata.replication.logging; | ||
|
||
import com.google.inject.Inject; | ||
|
||
/** | ||
* Facade that logs to both file and database. | ||
* | ||
* @see SLF4JAuditLogger | ||
* @see DatabaseAuditLogger | ||
* | ||
* @author Thomas Børlum (thb@trifork.com) | ||
*/ | ||
public class CompositeAuditLogger implements AuditLogger { | ||
|
||
private final DatabaseAuditLogger dbLogger; | ||
private final SLF4JAuditLogger fileLogger; | ||
|
||
@Inject | ||
CompositeAuditLogger(DatabaseAuditLogger dbLogger, SLF4JAuditLogger fileLogger) { | ||
|
||
this.dbLogger = dbLogger; | ||
this.fileLogger = fileLogger; | ||
} | ||
|
||
@Override | ||
public void log(String format, Object... args) { | ||
|
||
dbLogger.log(format, args); | ||
fileLogger.log(format, args); | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
...cts/replication/src/main/java/com/trifork/stamdata/replication/logging/LoggingModule.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,22 @@ | ||
package com.trifork.stamdata.replication.logging; | ||
|
||
import com.google.inject.Module; | ||
import com.google.inject.PrivateModule; | ||
|
||
|
||
public class LoggingModule extends PrivateModule implements Module { | ||
|
||
@Override | ||
protected void configure() { | ||
|
||
bind(DatabaseAuditLogger.class); | ||
bind(SLF4JAuditLogger.class); | ||
bind(AuditLogger.class).to(CompositeAuditLogger.class); | ||
expose(AuditLogger.class); | ||
|
||
// The Database logger is exposed too since it is needed | ||
// in the LogController, for historical reasons. | ||
|
||
expose(DatabaseAuditLogger.class); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
.../replication/src/main/java/com/trifork/stamdata/replication/logging/SLF4JAuditLogger.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,20 @@ | ||
package com.trifork.stamdata.replication.logging; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
/** | ||
* Logs audit messages using to a file using SLF4J. | ||
* | ||
* @author Thomas Børlum (thb@trifork.com) | ||
*/ | ||
public class SLF4JAuditLogger implements AuditLogger { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(AuditLogger.class); | ||
|
||
@Override | ||
public void log(String format, Object... args) { | ||
|
||
logger.info(String.format(format, args)); | ||
} | ||
} |
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