File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,11 +39,11 @@ func (p *fconsole) File() *os.File {
3939 return p .w
4040}
4141
42- func (p * fconsole ) Log (_ LogLevel , msg Logmsg ) {
42+ func (p * fconsole ) Log (lvl LogLevel , msg Logmsg ) {
4343 if p == nil || p .w == nil {
4444 return
4545 }
46- p .write (msg )
46+ p .write (lvl , msg )
4747}
4848
4949func setNonblock (f * os.File ) error {
@@ -53,7 +53,7 @@ func setNonblock(f *os.File) error {
5353 return syscall .SetNonblock (int (f .Fd ()), true )
5454}
5555
56- func (f * fconsole ) write (m Logmsg ) error {
56+ func (f * fconsole ) write (lvl LogLevel , m Logmsg ) error {
5757 if len (m ) == 0 {
5858 return nil
5959 }
@@ -67,6 +67,12 @@ func (f *fconsole) write(m Logmsg) error {
6767 }
6868 p := unsafe .StringData (m )
6969 b := unsafe .Slice (p , len (m ))
70+ // levels like STACKTRACE may not prefix the expected tag
71+ // ("F " in the STACKTRACE case), but file-based logger
72+ // always expects it for every line
73+ if ! bytes .HasPrefix ([]byte (lvl .s ()), b ) {
74+ w .Write (b )
75+ }
7076 n , err := w .Write (b )
7177 // go.dev/play/p/NbJimcpoS0o
7278 if ! bytes .HasSuffix (b , newline ) {
You can’t perform that action at this time.
0 commit comments