aboutsummaryrefslogtreecommitdiffstats
path: root/log.go
diff options
context:
space:
mode:
authorFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-06-25 00:10:52 +0900
committerFumitoshi Ukai <fumitoshi.ukai@gmail.com>2015-06-25 11:37:49 +0900
commit744bb2b8d146eaba4d073cf58e35a60903e06de8 (patch)
tree15d5c79f4e62428b3c427d0ce15e0076a92139de /log.go
parent44ae8cfdc153dd1a209b16453d5dbaa8b4f199d7 (diff)
downloadandroid_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.go20
1 files changed, 11 insertions, 9 deletions
diff --git a/log.go b/log.go
index b00e2bb..514ff9b 100644
--- a/log.go
+++ b/log.go
@@ -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)
}