Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 1 | package main |
| 2 | |
| 3 | import ( |
| 4 | "bytes" |
| 5 | "fmt" |
Shinichiro Hamaji | 0ec0770 | 2015-03-31 00:50:32 +0900 | [diff] [blame] | 6 | "os" |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 7 | ) |
| 8 | |
| 9 | func Log(f string, a ...interface{}) { |
Shinichiro Hamaji | 07259e0 | 2015-04-02 03:14:41 +0900 | [diff] [blame] | 10 | if noKatiLogFlag { |
| 11 | return |
| 12 | } |
| 13 | |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 14 | var buf bytes.Buffer |
| 15 | buf.WriteString("*kati*: ") |
| 16 | buf.WriteString(f) |
| 17 | buf.WriteByte('\n') |
| 18 | fmt.Printf(buf.String(), a...) |
| 19 | } |
| 20 | |
Shinichiro Hamaji | 7c4e325 | 2015-03-30 23:04:25 +0900 | [diff] [blame] | 21 | func Warn(filename string, lineno int, f string, a ...interface{}) { |
| 22 | f = fmt.Sprintf("%s:%d: warning: %s\n", filename, lineno, f) |
| 23 | fmt.Printf(f, a...) |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 24 | } |
| 25 | |
Shinichiro Hamaji | 0ec0770 | 2015-03-31 00:50:32 +0900 | [diff] [blame] | 26 | func Error(filename string, lineno int, f string, a ...interface{}) { |
| 27 | f = fmt.Sprintf("%s:%d: %s\n", filename, lineno, f) |
| 28 | fmt.Printf(f, a...) |
| 29 | os.Exit(2) |
Fumitoshi Ukai | 119dc91 | 2015-03-30 16:52:41 +0900 | [diff] [blame] | 30 | } |
Shinichiro Hamaji | b2fd38d | 2015-04-01 01:12:19 +0900 | [diff] [blame] | 31 | |
| 32 | func ErrorNoLocation(f string, a ...interface{}) { |
| 33 | f = fmt.Sprintf("%s\n", f) |
| 34 | fmt.Printf(f, a...) |
| 35 | os.Exit(2) |
| 36 | } |