Example #1
0
func (l *streamLogger) WriteLog(prefix, format string, v ...interface{}) {
	var data string
	if v == nil || len(v) == 0 {
		data = format
	} else {
		data = fmt.Sprintf(format, v...)
	}
	l.writer.Write([]byte(prefix + data + platform.LineSeparator()))
}
Example #2
0
func (this *FileLogWriter) run() {
	for {
		entry, open := <-this.queue
		if !open {
			break
		}
		this.logger.Print(entry + platform.LineSeparator())
	}
}
Example #3
0
func newFileAccessLogger(path string) accessLogger {
	file, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
	if err != nil {
		log.Printf("Unable to create or open file (%s): %v%s", path, err, platform.LineSeparator())
		return nil
	}
	return &fileAccessLogger{
		queue:  make(chan *accessLog, 16),
		logger: log.New(file, "", log.Ldate|log.Ltime),
		file:   file,
	}
}
Example #4
0
func TestStreamLogger(t *testing.T) {
	v2testing.Current(t)

	buffer := bytes.NewBuffer(make([]byte, 0, 1024))
	infoLogger = &stdOutLogWriter{
		logger: log.New(buffer, "", 0),
	}
	Info("Test ", "Stream Logger", " Format")
	assert.StringLiteral(string(buffer.Bytes())).Equals("[Info]Test Stream Logger Format" + platform.LineSeparator())

	buffer.Reset()
	errorLogger = infoLogger
	Error("Test ", serial.StringLiteral("literal"), " Format")
	assert.StringLiteral(string(buffer.Bytes())).Equals("[Error]Test literal Format" + platform.LineSeparator())
}
Example #5
0
func PrintVersion() {
	fmt.Printf("V2Ray %s (%s) %s%s", version, codename, build, platform.LineSeparator())
	fmt.Printf("%s%s", intro, platform.LineSeparator())
}
Example #6
0
func (this *fileLogWriter) run() {
	for entry := range this.queue {
		this.logger.Print(entry.String() + platform.LineSeparator())
	}
}
Example #7
0
func (this *stdOutLogWriter) Log(log serial.String) {
	this.logger.Print(log.String() + platform.LineSeparator())
}
Example #8
0
func (this *StdOutLogWriter) Log(log LogEntry) {
	this.logger.Print(log.String() + platform.LineSeparator())
	log.Release()
}