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

clean

parent 7c3f032c
...@@ -9,6 +9,7 @@ import ( ...@@ -9,6 +9,7 @@ import (
"unsafe" "unsafe"
"net/http" "net/http"
"crypto/tls" "crypto/tls"
"strings"
"github.com/fluent/fluent-bit-go/output" "github.com/fluent/fluent-bit-go/output"
) )
...@@ -77,7 +78,7 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int ...@@ -77,7 +78,7 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int
for _, s := range v.([]uint8) { for _, s := range v.([]uint8) {
output_string = output_string + string(s) output_string = output_string + string(s)
} }
if output_string == "fluentbit_end" { if strings.Contains(output_string, "fluentbit_end") {
is_end = true is_end = true
} }
result = result + output_string + "]" result = result + output_string + "]"
...@@ -110,9 +111,10 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int ...@@ -110,9 +111,10 @@ func FLBPluginFlushCtx(ctx, data unsafe.Pointer, length C.int, tag *C.char) int
rsp, err := client.Do(req) rsp, err := client.Do(req)
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "got error %s", err.Error()) fmt.Fprintf(os.Stderr, "got error %s", err.Error())
return output.FLB_RETRY
} }
if rsp.StatusCode != 204 { if rsp.StatusCode != 204 {
fmt.Printf("status code %d", rsp.StatusCode) fmt.Fprintf(os.Stderr, "status code %d", rsp.StatusCode)
return output.FLB_RETRY return output.FLB_RETRY
} }
if is_end { if is_end {
......
use anyhow::Result; use anyhow::Result;
use clap::{App, Arg}; use clap::{App, Arg};
use rayon::prelude::*; use rayon::prelude::*;
use reqwest::{
blocking::{self, Client},
header, redirect,
};
use serde::Serialize; use serde::Serialize;
use std::collections::HashMap; use std::collections::HashMap;
use std::{ use std::{
ffi::OsString, ffi::OsString,
fs::DirEntry, fs::DirEntry,
io::{Cursor, Read},
path::PathBuf, path::PathBuf,
sync::{Arc, Mutex}, sync::{Arc, Mutex},
thread,
time::Duration,
}; };
use std::process::Command; use std::process::Command;
...@@ -256,8 +249,10 @@ fn main() -> Result<()> { ...@@ -256,8 +249,10 @@ fn main() -> Result<()> {
}; };
let packed = serde_json::to_string(&snapshot)?; let packed = serde_json::to_string(&snapshot)?;
for s in packed.split(":{"){ 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(); let _result = child.wait().unwrap();
Ok(()) 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