Commit 8f9b2d3a authored by Xiaowu Zhang's avatar Xiaowu Zhang

clean

parent 7c3f032c
......@@ -9,6 +9,7 @@ import (
"unsafe"
"net/http"
"crypto/tls"
"strings"
"github.com/fluent/fluent-bit-go/output"
)
......@@ -77,7 +78,7 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int
for _, s := range v.([]uint8) {
output_string = output_string + string(s)
}
if output_string == "fluentbit_end" {
if strings.Contains(output_string, "fluentbit_end") {
is_end = true
}
result = result + output_string + "]"
......@@ -110,9 +111,10 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int
rsp, err := client.Do(req)
if err != nil {
fmt.Fprintf(os.Stderr, "got error %s", err.Error())
return output.FLB_RETRY
}
if rsp.StatusCode != 204 {
fmt.Printf("status code %d", rsp.StatusCode)
fmt.Fprintf(os.Stderr, "status code %d", rsp.StatusCode)
return output.FLB_RETRY
}
if is_end {
......
use anyhow::Result;
use clap::{App, Arg};
use rayon::prelude::*;
use reqwest::{
blocking::{self, Client},
header, redirect,
};
use serde::Serialize;
use std::collections::HashMap;
use std::{
ffi::OsString,
fs::DirEntry,
io::{Cursor, Read},
path::PathBuf,
sync::{Arc, Mutex},
thread,
time::Duration,
};
use std::process::Command;
......@@ -256,8 +249,10 @@ fn main() -> Result<()> {
};
let packed = serde_json::to_string(&snapshot)?;
for s in packed.split(":{"){
file.write_all((s.to_owned()+"\n").as_bytes());
file.write_all((s.to_owned()+"\n").as_bytes()).expect("Unable to write to log");
}
file.write_all("fluentbit_end\n".as_bytes()).expect("Unable to write to log");
println!("finished to write file");
let _result = child.wait().unwrap();
Ok(())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment