
com.reprezen.genflow.api.util.GenLogSupport Maven / Gradle / Ivy
/*******************************************************************************
* Copyright © 2013, 2016 Modelsolv, Inc.
* All Rights Reserved.
*
* NOTICE: All information contained herein is, and remains the property
* of ModelSolv, Inc. See the file license.html in the root directory of
* this project for further information.
*******************************************************************************/
package com.reprezen.genflow.api.util;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.LogRecord;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.common.collect.Lists;
public class GenLogSupport {
private final ObjectMapper mapper;
private static final String YAML_DOC_PREFIX = "---";
public GenLogSupport() {
mapper = new ObjectMapper(new YAMLFactory());
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
public String toWriteString(LogRecord record) throws JsonProcessingException {
String serialized = mapper.writeValueAsString(Lists.newArrayList(record));
if (serialized.startsWith(YAML_DOC_PREFIX)) {
serialized = serialized.substring(YAML_DOC_PREFIX.length());
}
return serialized;
}
public List fromString(File logFile) throws JsonParseException, JsonMappingException, IOException {
List result = Lists.newArrayList();
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy