-
Notifications
You must be signed in to change notification settings - Fork 15
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
Showing
8 changed files
with
89 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
project_description = Extra exception mapping providers |
16 changes: 16 additions & 0 deletions
16
logback-json-exception-mapping/logback-json-exception-mapping.gradle
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,16 @@ | ||
dependencies { | ||
compile project(':logback-exception-mapping') | ||
compile project(':logback-typesafe-config') | ||
|
||
compile "net.logstash.logback:logstash-logback-encoder:$logstashVersion" | ||
} | ||
|
||
config { | ||
javadoc { | ||
options.charSet = 'UTF-8' | ||
options.encoding = 'UTF-8' | ||
options.docEncoding = 'UTF-8' | ||
options.use = true | ||
options.links = [jvmToJavadoc(targetCompatibility)] + javadocFromDependencies(configurations.compile) | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...redconfig/ExceptionArgumentsProvider.java → ...onmapping/ExceptionArgumentsProvider.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
61 changes: 61 additions & 0 deletions
61
...pping/src/main/java/com/tersesystems/logback/exceptionmapping/TypesafeConfigMappings.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,61 @@ | ||
package com.tersesystems.logback.exceptionmapping; | ||
|
||
import ch.qos.logback.core.joran.action.Action; | ||
import ch.qos.logback.core.joran.spi.ActionException; | ||
import ch.qos.logback.core.joran.spi.InterpretationContext; | ||
import com.tersesystems.logback.exceptionmapping.ExceptionMappingRegistry; | ||
import com.tersesystems.logback.typesafeconfig.ConfigConstants; | ||
import com.typesafe.config.Config; | ||
import org.xml.sax.Attributes; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class TypesafeConfigMappings extends Action { | ||
|
||
@SuppressWarnings("unchecked") | ||
private ExceptionMappingRegistry getRegistry(InterpretationContext ic) { | ||
Object obj = ic.peekObject(); | ||
if (obj == null) { | ||
addError("Not in an exception registry"); | ||
return null; | ||
} | ||
|
||
if (obj instanceof ExceptionMappingRegistry) { | ||
return (ExceptionMappingRegistry) obj; | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public void begin(InterpretationContext ic, String name, Attributes attributes) throws ActionException { | ||
ExceptionMappingRegistry registry = getRegistry(ic); | ||
Config config = getConfig(ic); | ||
|
||
if (registry != null && config != null) { | ||
Map<String, List<String>> mappings = getMappingsFromConfig(); | ||
registry.register(mappings); | ||
} | ||
} | ||
|
||
private Config getConfig(InterpretationContext ic) { | ||
Object obj = ic.getObjectMap().get(ConfigConstants.TYPESAFE_CONFIG_CTX_KEY); | ||
if (obj == null) { | ||
addError("No typesafe config found in object map!"); | ||
return null; | ||
} | ||
if (obj instanceof Config) { | ||
return (Config) obj; | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public void end(InterpretationContext ic, String name) throws ActionException { | ||
|
||
} | ||
|
||
public Map<String, List<String>> getMappingsFromConfig() { | ||
return null; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...t/java/com/tersesystems/logback/exceptionmapping/json/ExceptionArgumentsProviderTest.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,4 @@ | ||
package com.tersesystems.logback.exceptionmapping.json; | ||
|
||
public class ExceptionArgumentsProviderTest { | ||
} |
4 changes: 4 additions & 0 deletions
4
.../test/java/com/tersesystems/logback/exceptionmapping/json/TypesafeConfigMappingsTest.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,4 @@ | ||
package com.tersesystems.logback.exceptionmapping.json; | ||
|
||
public class TypesafeConfigMappingsTest { | ||
} |
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