You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
708 B
48 lines
708 B
package fibs |
|
|
|
import ( |
|
"fmt" |
|
"io" |
|
"log" |
|
"time" |
|
) |
|
|
|
var ( |
|
StatusWriter io.Writer |
|
GameWriter io.Writer |
|
|
|
statusLogged bool |
|
gameLogged bool |
|
) |
|
|
|
func l(s string) { |
|
m := time.Now().Format("15:04") + "| " + s |
|
if StatusWriter != nil { |
|
if statusLogged { |
|
StatusWriter.Write([]byte("\n" + m)) |
|
return |
|
} |
|
StatusWriter.Write([]byte(m)) |
|
statusLogged = true |
|
return |
|
} |
|
log.Print(m) |
|
} |
|
|
|
func lf(format string, a ...interface{}) { |
|
l(fmt.Sprintf(format, a...)) |
|
} |
|
|
|
func lg(s string) { |
|
m := time.Now().Format("15:04") + "| " + s |
|
if GameWriter != nil { |
|
if gameLogged { |
|
GameWriter.Write([]byte("\n" + m)) |
|
return |
|
} |
|
GameWriter.Write([]byte(m)) |
|
gameLogged = true |
|
return |
|
} |
|
log.Print(m) |
|
}
|
|
|