/*
 * dump each message to the file
 */
dump each message to the file
/ * * dump each message to the file * /
func (f *File) dumpMessage(msg *message.Msg) (*message.Msg, error) {
	var line string
	if msg.IsMap() {
		ba, err := json.Marshal(msg.Map())
		if err != nil {
			f.pipe.Err <- adaptor.NewError(adaptor.ERROR, f.path, fmt.Sprintf("Can't unmarshal document (%s)", err.Error()), msg.Data)
			return msg, nil
		}
		line = string(ba)
	} else {
		line = fmt.Sprintf("%v", msg.Data)
	}
	if strings.HasPrefix(f.uri, "stdout://") {
		fmt.Println(line)
	} else {
		_, err := fmt.Fprintln(f.filehandle, line)
		if err != nil {
			f.pipe.Err <- adaptor.NewError(adaptor.ERROR, f.path, fmt.Sprintf("Error writing to file (%s)", err.Error()), msg.Data)
			return msg, nil
		}
	}
	return msg, nil
}
func ( f * File ) dumpMessage ( msg * message . Msg ) ( * message . Msg , error ) { var line string if msg . IsMap ( ) { ba , err := json . Marshal ( msg . Map ( ) ) if err != nil { f . pipe . Err <- adaptor . NewError ( adaptor . ERROR , f . path , fmt . Sprintf ( " " , err . Error ( ) ) , msg . Data ) return msg , nil } line = string ( ba ) } else { line = fmt . Sprintf ( " " , msg . Data ) } if strings . HasPrefix ( f . uri , " " ) { fmt . Println ( line ) } else { _ , err := fmt . Fprintln ( f . filehandle , line ) if err != nil { f . pipe . Err <- adaptor . NewError ( adaptor . ERROR , f . path , fmt . Sprintf ( " " , err . Error ( ) ) , msg . Data ) return msg , nil } } return msg , nil }
dump each message to the file
dump each message to the file