// Path: fluency-core/src/main/java/org/komamitsu/fluency/recordformat/AbstractRecordFormatter.java
// public abstract class AbstractRecordFormatter
//         implements RecordFormatter
// {
//     private static final Logger LOG = LoggerFactory.getLogger(AbstractRecordFormatter.class);
//     protected final ObjectMapper objectMapperForMessagePack = new ObjectMapper(new MessagePackFactory());
//     protected final Config config;
// 
//     public AbstractRecordFormatter(Config config)
//     {
//         this.config = config;
//         registerObjectMapperModules(objectMapperForMessagePack);
//     }
// 
//     public abstract byte[] format(String tag, Object timestamp, Map<String, Object> data);
// 
//     public abstract byte[] formatFromMessagePack(String tag, Object timestamp, byte[] mapValue, int offset, int len);
// 
//     public abstract byte[] formatFromMessagePack(String tag, Object timestamp, ByteBuffer mapValue);
// 
//     public abstract String formatName();
// 
//     protected long getEpoch(Object timestamp)
//     {
//         if (timestamp instanceof EventTime) {
//             return ((EventTime) timestamp).getSeconds();
//         }
//         else if (timestamp instanceof Number) {
//             return ((Number) timestamp).longValue();
//         }
//         else {
//             LOG.warn("Invalid timestamp. Using current time: timestamp={}", timestamp);
//             return System.currentTimeMillis() / 1000;
//         }
//     }
// 
//     protected void registerObjectMapperModules(ObjectMapper objectMapper)
//     {
//         List<Module> jacksonModules = config.getJacksonModules();
//         for (Module module : jacksonModules) {
//             objectMapper.registerModule(module);
//         }
//     }
// }
// 
// Path: fluency-core/src/main/java/org/komamitsu/fluency/recordformat/RecordFormatter.java
// public interface RecordFormatter
// {
//     byte[] format(String tag, Object timestamp, Map<String, Object> data);
// 
//     byte[] formatFromMessagePack(String tag, Object timestamp, byte[] mapValue, int offset, int len);
// 
//     byte[] formatFromMessagePack(String tag, Object timestamp, ByteBuffer mapValue);
// 
//     String formatName();
// 
//     class Config
//     {
//         private List<Module> jacksonModules = Collections.emptyList();
// 
//         public List<Module> getJacksonModules()
//         {
//             return jacksonModules;
//         }
// 
//         public void setJacksonModules(List<Module> jacksonModules)
//         {
//             this.jacksonModules = jacksonModules;
//         }
//     }
// }


import com.fasterxml.jackson.core.JsonProcessingException;
import org.komamitsu.fluency.recordformat.AbstractRecordFormatter;
import org.komamitsu.fluency.recordformat.RecordFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Map;
/*
 * Copyright 2019 Mitsunori Komatsu (komamitsu)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.komamitsu.fluency.fluentd.recordformat;



public class FluentdRecordFormatter
        extends AbstractRecordFormatter
// Path: fluency-core/src/main/java/org/komamitsu/fluency/recordformat/AbstractRecordFormatter.java
// public abstract class AbstractRecordFormatter
//         implements RecordFormatter
// {
//     private static final Logger LOG = LoggerFactory.getLogger(AbstractRecordFormatter.class);
//     protected final ObjectMapper objectMapperForMessagePack = new ObjectMapper(new MessagePackFactory());
//     protected final Config config;
// 
//     public AbstractRecordFormatter(Config config)
//     {
//         this.config = config;
//         registerObjectMapperModules(objectMapperForMessagePack);
//     }
// 
//     public abstract byte[] format(String tag, Object timestamp, Map<String, Object> data);
// 
//     public abstract byte[] formatFromMessagePack(String tag, Object timestamp, byte[] mapValue, int offset, int len);
// 
//     public abstract byte[] formatFromMessagePack(String tag, Object timestamp, ByteBuffer mapValue);
// 
//     public abstract String formatName();
// 
//     protected long getEpoch(Object timestamp)
//     {
//         if (timestamp instanceof EventTime) {
//             return ((EventTime) timestamp).getSeconds();
//         }
//         else if (timestamp instanceof Number) {
//             return ((Number) timestamp).longValue();
//         }
//         else {
//             LOG.warn("Invalid timestamp. Using current time: timestamp={}", timestamp);
//             return System.currentTimeMillis() / 1000;
//         }
//     }
// 
//     protected void registerObjectMapperModules(ObjectMapper objectMapper)
//     {
//         List<Module> jacksonModules = config.getJacksonModules();
//         for (Module module : jacksonModules) {
//             objectMapper.registerModule(module);
//         }
//     }
// }
// 
// Path: fluency-core/src/main/java/org/komamitsu/fluency/recordformat/RecordFormatter.java
// public interface RecordFormatter
// {
//     byte[] format(String tag, Object timestamp, Map<String, Object> data);
// 
//     byte[] formatFromMessagePack(String tag, Object timestamp, byte[] mapValue, int offset, int len);
// 
//     byte[] formatFromMessagePack(String tag, Object timestamp, ByteBuffer mapValue);
// 
//     String formatName();
// 
//     class Config
//     {
//         private List<Module> jacksonModules = Collections.emptyList();
// 
//         public List<Module> getJacksonModules()
//         {
//             return jacksonModules;
//         }
// 
//         public void setJacksonModules(List<Module> jacksonModules)
//         {
//             this.jacksonModules = jacksonModules;
//         }
//     }
// }


// Path: fluency-fluentd/src/main/java/org/komamitsu/fluency/fluentd/recordformat/FluentdRecordFormatter.java
import com.fasterxml.jackson.core.JsonProcessingException;
import org.komamitsu.fluency.recordformat.AbstractRecordFormatter;
import org.komamitsu.fluency.recordformat.RecordFormatter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.Map;

/*
 * Copyright 2019 Mitsunori Komatsu (komamitsu)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.komamitsu.fluency.fluentd.recordformat;



public class FluentdRecordFormatter
        extends AbstractRecordFormatter
        implements RecordFormatter