diff options
author | Fumitoshi Ukai <fumitoshi.ukai@gmail.com> | 2015-06-25 00:10:52 +0900 |
---|---|---|
committer | Fumitoshi Ukai <fumitoshi.ukai@gmail.com> | 2015-06-25 11:37:49 +0900 |
commit | 744bb2b8d146eaba4d073cf58e35a60903e06de8 (patch) | |
tree | 15d5c79f4e62428b3c427d0ce15e0076a92139de /log.go | |
parent | 44ae8cfdc153dd1a209b16453d5dbaa8b4f199d7 (diff) | |
download | android_build_kati-744bb2b8d146eaba4d073cf58e35a60903e06de8.tar.gz android_build_kati-744bb2b8d146eaba4d073cf58e35a60903e06de8.tar.bz2 android_build_kati-744bb2b8d146eaba4d073cf58e35a60903e06de8.zip |
go gettable for github.com/google/kati
Diffstat (limited to 'log.go')
-rw-r--r-- | log.go | 20 |
1 files changed, 11 insertions, 9 deletions
@@ -12,13 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -package main +package kati import ( "bytes" "fmt" "os" - "runtime/pprof" "sync" ) @@ -35,14 +34,14 @@ func LogAlways(f string, a ...interface{}) { } func LogStats(f string, a ...interface{}) { - if !katiLogFlag && !katiStatsFlag { + if !LogFlag && !StatsFlag { return } LogAlways(f, a...) } func Logf(f string, a ...interface{}) { - if !katiLogFlag { + if !LogFlag { return } LogAlways(f, a...) @@ -58,19 +57,22 @@ func WarnNoPrefix(filename string, lineno int, f string, a ...interface{}) { fmt.Printf(f, a...) } +var atErrors []func() + +func AtError(f func()) { + atErrors = append(atErrors, f) +} + func Error(filename string, lineno int, f string, a ...interface{}) { f = fmt.Sprintf("%s:%d: %s", filename, lineno, f) - maybeWriteHeapProfile() ErrorNoLocation(f, a...) } func ErrorNoLocation(f string, a ...interface{}) { f = fmt.Sprintf("%s\n", f) fmt.Printf(f, a...) - if cpuprofile != "" { - pprof.StopCPUProfile() + for i := len(atErrors) - 1; i >= 0; i-- { + atErrors[i]() } - maybeWriteHeapProfile() - dumpStats() os.Exit(2) } |