blob: 78060b1e1462d3c97e5643e4371509de9b1871ba [file] [log] [blame]
Fumitoshi Ukai119dc912015-03-30 16:52:41 +09001package main
2
3import (
4 "bytes"
5 "fmt"
Shinichiro Hamaji0ec07702015-03-31 00:50:32 +09006 "os"
Shinichiro Hamajib0a0cf62015-04-11 10:25:36 +09007 "runtime/pprof"
Fumitoshi Ukai119dc912015-03-30 16:52:41 +09008)
9
10func Log(f string, a ...interface{}) {
Fumitoshi Ukaib07bcc32015-04-07 12:03:31 +090011 if !katiLogFlag {
Shinichiro Hamaji07259e02015-04-02 03:14:41 +090012 return
13 }
14
Fumitoshi Ukai119dc912015-03-30 16:52:41 +090015 var buf bytes.Buffer
16 buf.WriteString("*kati*: ")
17 buf.WriteString(f)
18 buf.WriteByte('\n')
19 fmt.Printf(buf.String(), a...)
20}
21
Shinichiro Hamaji7c4e3252015-03-30 23:04:25 +090022func Warn(filename string, lineno int, f string, a ...interface{}) {
23 f = fmt.Sprintf("%s:%d: warning: %s\n", filename, lineno, f)
24 fmt.Printf(f, a...)
Fumitoshi Ukai119dc912015-03-30 16:52:41 +090025}
26
Shinichiro Hamajia06760f2015-04-07 13:13:45 +090027func WarnNoPrefix(filename string, lineno int, f string, a ...interface{}) {
28 f = fmt.Sprintf("%s:%d: %s\n", filename, lineno, f)
29 fmt.Printf(f, a...)
30}
31
Shinichiro Hamaji0ec07702015-03-31 00:50:32 +090032func Error(filename string, lineno int, f string, a ...interface{}) {
Shinichiro Hamajib0a0cf62015-04-11 10:25:36 +090033 f = fmt.Sprintf("%s:%d: %s", filename, lineno, f)
34 ErrorNoLocation(f, a...)
Fumitoshi Ukai119dc912015-03-30 16:52:41 +090035}
Shinichiro Hamajib2fd38d2015-04-01 01:12:19 +090036
37func ErrorNoLocation(f string, a ...interface{}) {
38 f = fmt.Sprintf("%s\n", f)
39 fmt.Printf(f, a...)
Shinichiro Hamajib0a0cf62015-04-11 10:25:36 +090040 if cpuprofile != "" {
41 pprof.StopCPUProfile()
42 }
Shinichiro Hamajib2fd38d2015-04-01 01:12:19 +090043 os.Exit(2)
44}