// Write is standard writer for this log library. It used when standard log is captured to route all log messages into
// this library. Regexp is used to extract message level from text
Write is standard writer for this log library. It used when standard log is captured to route all log messages into
this library. Regexp is used to extract message level from text
// Write is standard writer for this log library . It used when standard log is captured to route all log messages into // this library . Regexp is used to extract message level from text
func (t *logger) Write(buf []byte) (ln int, err error) {
	level := L_notice
	m := msgLevelCheck.FindSubmatch(buf)
	if len(m) == 3 {
		buf = bytes.Replace(buf, m[1], []byte(""), 1)
		letter := bytes.ToLower(m[2][0:1])
		switch letter[0] {
		case 'f':
			level = L_fatal
		case 'a':
			level = L_alert
		case 'c':
			level = L_critical
		case 'e':
			level = L_error
		case 'w':
			level = L_warning
		case 'n':
			level = L_notice
		case 'i':
			level = L_info
		case 'd':
			level = L_debug
		default:
		}
	}
	ln = len(buf)
	i := []interface{}{string(bytes.TrimSpace(buf))}
	err = outputMessage("", i, level, 4)
	if level == L_fatal {
		os.Exit(-1)
	}
	return
}
func ( t * logger ) Write ( buf [ ] byte ) ( ln int , err error ) { level := L_notice m := msgLevelCheck . FindSubmatch ( buf ) if len ( m ) == 3 { buf = bytes . Replace ( buf , m [ 1 ] , [ ] byte ( " " ) , 1 ) letter := bytes . ToLower ( m [ 2 ] [ 0 : 1 ] ) switch letter [ 0 ] { case 'f' : level = L_fatal case 'a' : level = L_alert case 'c' : level = L_critical case 'e' : level = L_error case 'w' : level = L_warning case 'n' : level = L_notice case 'i' : level = L_info case 'd' : level = L_debug default : } } ln = len ( buf ) i := [ ] interface { } { string ( bytes . TrimSpace ( buf ) ) } err = outputMessage ( " " , i , level , 4 ) if level == L_fatal { os . Exit ( - 1 ) } return }
Write is standard writer for this log library.
Write is standard writer for this log library .