JSONSerializer extends Converter<LogRecord, String> { @Override protected String doForward(final LogRecord record) { final JSONLoggingRecord jlr = new JSONLoggingRecord(); jlr.event = "exposure"; jlr.timestamp = ISO.format(new Date()); jlr.namespace = record.namespace.getName(); jlr.salt = record.namespace.nsConf.salt; final Experiment exp = MoreObjects.firstNonNull(record.namespace.getExperiment(), record.namespace.nsConf.getDefaultExperiment()); jlr.experiment = exp.name; jlr.checksum = CHECKSUM.hashUnencodedChars(exp.def.getCopyOfScript().toString()).toString(); jlr.inputs = record.input; jlr.overrides = record.overrides; jlr.params = record.namespace.getParams(); return gson.toJson(jlr); } JSONSerializer();  JSONSerializer(final boolean pretty);   }
@Test public void testSerialization() { final JSONSerializer ser = new JSONSerializer(); final NamespaceConfig nsConf = new NamespaceConfig("test_ns", 100, "userid", null); nsConf.defineExperiment("def", (Map<String, ?>)TEST_DEF); nsConf.setDefaultExperiment("def"); nsConf.addExperiment("def_exp", "def", 100); nsConf.noMoreChanges(); final Map<String, ?> input = ImmutableMap.of("userid", 12345); final Namespace ns = new Namespace(nsConf, input, null); System.out.println(ser.doForward(new LogRecord(ns, input, null))); }