Пример #1
0
func init() {
	dsn := DsnTcpIpV4("root", "123", "127.0.0.1", "3306", "test")

	path := "/tmp/test_mysql.log"

	w, _ := writer.NewFileWriter(path)
	logger, _ := log.NewSimpleLogger(w, log.LEVEL_INFO, new(log.SimpleFormater))

	dao, _ = NewDao(dsn, logger)
}
Пример #2
0
func TestSimpleLogger(t *testing.T) {
	fw, _ := writer.NewFileWriter("/tmp/test_simple_logger.log")
	logger, _ := NewSimpleLogger(fw, LEVEL_INFO, new(SimpleFormater))

	msg := []byte("test simple logger")

	testLogger(logger, msg)

	logger.Free()
}
Пример #3
0
func TestSimpleBufferLogger(t *testing.T) {
	fw, _ := writer.NewFileWriter("/tmp/test_simple_buffer_logger.log")
	bw := buffer.NewBuffer(fw, 1024)
	logger, _ := NewSimpleLogger(bw, LEVEL_INFO, new(SimpleFormater))

	msg := []byte("test simple buffer logger")

	testLogger(logger, msg)

	logger.Free()
}
Пример #4
0
func TestBufferFileWriter(t *testing.T) {
	path := "/tmp/test_buffer.log"
	bufsize := 4096

	fw, _ := writer.NewFileWriter(path)
	bw := NewBuffer(fw, bufsize)

	bw.Write([]byte("test file writer with buffer and time interval\n"))
	time.Sleep(time.Second * 5)
	bw.Free()
}
Пример #5
0
func TestSimpleLogger(t *testing.T) {
	path := "/tmp/test.log"

	w, _ := logWriter.NewFileWriter(path)
	writer := logWriter.NewBufferWriter(w, 1024)

	logger, _ := NewSimpleLogger(writer, LEVEL_INFO)
	msg := []byte("test simple logger")

	testLogger(logger, msg)
	logger.Free()
}
Пример #6
0
func asyncLogger2(wg *sync.WaitGroup) {
	defer wg.Done()

	path := "/tmp/test_a2.log"

	w, _ := logWriter.NewFileWriter(path)
	writer, _ := logWriter.NewBufferWriterWithTimeFlush(w, 1024, time.Second*2)

	l, _ := NewSimpleLogger(writer, LEVEL_INFO)
	logger, _ := NewAsyncLogger(l, 10)
	msg := []byte("test async2 logger")

	testLogger(logger, msg)
}
Пример #7
0
func asyncWebLogger(wg *sync.WaitGroup) {
	defer wg.Done()

	fw, _ := writer.NewFileWriter("/tmp/test_async_web_logger.log")
	bw := buffer.NewBuffer(fw, 1024)
	sl, _ := NewSimpleLogger(bw, LEVEL_INFO, NewWebFormater([]byte("async_web"), []byte("127.0.0.1")))
	logger := NewAsyncLogger(sl, NewAsyncLogRoutine(10))

	msg := []byte("test async web logger")

	testLogger(logger, msg)

	logger.Free()
}
Пример #8
0
func asyncSimpleLogger(wg *sync.WaitGroup) {
	defer wg.Done()

	fw, _ := writer.NewFileWriter("/tmp/test_async_simple_logger.log")
	bw := buffer.NewBuffer(fw, 1024)
	sl, _ := NewSimpleLogger(bw, LEVEL_INFO, new(SimpleFormater))
	logger := NewAsyncLogger(sl, NewAsyncLogRoutine(10))

	msg := []byte("test async simple logger")

	testLogger(logger, msg)
	time.Sleep(time.Second * 3)

	logger.Free()
}
Пример #9
0
Файл: main.go Проект: Andals/gpm
func main() {
	if flag.NArg() < 1 {
		fmt.Println("Usage: andals-gpm install")
		return
	}

	cmd, err := commands.GetCommand(flag.Arg(0))
	if err != nil {
		fmt.Println(err.Error())
		return
	}

	writer, _ := logWriter.NewFileWriter("/dev/stdout")
	logger, _ := log.NewSimpleLogger(writer, conf.GetLogLevel())

	prjHome, _ := os.Getwd()
	cmd.Run(prjHome, logger)
}
Пример #10
0
func TestClientGet(t *testing.T) {
	path := "/tmp/test_http_client.log"
	w, _ := logWriter.NewFileWriter(path)
	logger, _ := log.NewSimpleLogger(w, log.LEVEL_INFO)

	client := NewClient(logger).SetTimeout(time.Second * 3).SetMaxIdleConnsPerHost(10)
	extHeaders := map[string]string{
		"GO-CLIENT-1": "gobox-httpclient-1",
		"GO-CLIENT-2": "gobox-httpclient-2",
	}
	req, _ := NewRequestForGet("http://www.vdocker.com/test.php", "127.0.0.1", extHeaders)

	resp, err := client.Do(req, 1)
	fmt.Println(string(resp.Contents), resp.T.String(), err)

	req, _ = NewRequestForGet("http://www.vdocker.com/index.html", "127.0.0.1", extHeaders)

	resp, err = client.Do(req, 1)
	fmt.Println(string(resp.Contents), resp.T.String(), err)
}