gwriter

package module
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 3, 2019 License: MIT Imports: 2 Imported by: 0

README

Logger module for go

Build Status GoDoc GitHub license

func ExampleNewWriter() {
	conf := config.Config{
		PathTpl:  "{dir}/{filename}{base_ext}{write_ext}",
		BaseExt:  ".msg",
		WriteExt: "",
		PathInfo: map[string]string{
			"{dir}":      os.Getenv("DIR"),
			"{filename}": os.Getenv("FILENAME"),
		},
		UpdateMoment: "00:01:00",
	}

	writer := NewWriter("test-file", conf)
	writer.Start()
	writer.WriteString("this is string")
	writer.WriteBytes([]byte("this is bytes"))
	writer.Stop()
}

Documentation

Overview

Package writer is an file library for appending file.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Writer

type Writer interface {
	WriteString(s string)
	WriteBytes(bs []byte)
	Start()
	Stop()
}

Writer is the interface of writer implementations

func NewWriter

func NewWriter(name string, config config.Config) (w Writer)

NewWriter creates a new writer instance of basicWriter match Writer interface

Example

example of creating new writer

conf := config.Config{
	PathTpl:  "{dir}/{filename}{base_ext}{write_ext}",
	BaseExt:  ".msg",
	WriteExt: "",
	PathInfo: map[string]string{
		"{dir}":      os.Getenv("DIR"),
		"{filename}": os.Getenv("FILENAME"),
	},
	UpdateMoment: "00:01:00",
}

writer := NewWriter("心跳消息文件", conf)
writer.Start()
writer.WriteString("this is string")
writer.WriteBytes([]byte("this is bytes"))
writer.Stop()

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL