package com.ctrip.ops.sysdev.outputs;

import java.util.Map;

import com.ctrip.ops.sysdev.baseplugin.BaseOutput;
import lombok.extern.log4j.Log4j2;

@Log4j2
public class Stdout extends BaseOutput {

    public Stdout(Map config) {
        super(config);
    }

    @Override
    protected void prepare() {
    }

    @Override
    protected void emit(Map event) {
        System.out.println(event);
    }
}


@@ -32,16 +32,44 @@
 tputs;%0A%0A
+import java.io.IOException;%0A
 import j
@@ -145,34 +145,119 @@
 ort 
-lombok.extern.log4j.Log4j2
+com.ctrip.ops.sysdev.render.TemplateRender;%0Aimport lombok.extern.log4j.Log4j2;%0Aimport org.json.simple.JSONValue
 ;%0A%0A@
@@ -305,16 +305,52 @@
 tput %7B%0A%0A
+    private TemplateRender format;%0A%0A
     publ
@@ -456,96 +456,720 @@
     
-%7D%0A%0A    @Override%0A    protected void emit(Map event) %7B%0A        System.out.println(event);
+    if (this.config.containsKey(%22format%22)) %7B%0A            String format = (String) this.config.get(%22format%22);%0A            try %7B%0A                this.format = TemplateRender.getRender(format);%0A            %7D catch (IOException e) %7B%0A                log.fatal(%22could not build template from%22 + format);%0A                System.exit(1);%0A            %7D%0A        %7D else %7B%0A            this.format = null;%0A        %7D%0A    %7D%0A%0A    @Override%0A    protected void emit(Map event) %7B%0A        if (this.format == null) %7B%0A            System.out.println(event);%0A        %7D else %7B%0A            Object message = this.format.render(event);%0A            if (message != null) %7B%0A                System.out.println(message);%0A            %7D%0A        %7D%0A
 %0A   

format render