Last active
August 29, 2015 14:17
-
-
Save sripathikrishnan/dea0f9d579dd37040430 to your computer and use it in GitHub Desktop.
Possible Interface for Structured Logging in Java
This file contains hidden or 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
| import org.slf4j.Logger; | |
| import org.slf4j.LoggerFactory; | |
| import static com.hashedin.logan.utils.$; | |
| public class HelloStructuredLogging { | |
| private static final Logger LOGGER = LoggerFactory.getLogger(GobblerServerHandler.class); | |
| public static void main(String args[]) { | |
| LOGGER.info("tweet_dispatched_to_room", | |
| $("tweetid", "42323123112", | |
| "twitter_handle", "@srithedabbler", | |
| "room_name", "Twitter Test Room", | |
| "tenant_id", "3242342432423", | |
| "account", "HashedIn" | |
| ) | |
| ); | |
| } | |
| } |
This file contains hidden or 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
| public static final Map<String, String> _(String ...args) { | |
| Map<String, String> map = new HashMap<String, String>(); | |
| if ((args.length %2) != 0) { | |
| throw new IllegalArgumentException("Mismatched keys and values"); | |
| } | |
| for(int i=0; i<args.length-1; i+=2) { | |
| map.put(args[i], args[i+1]); | |
| } | |
| return map; | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment