Last active
March 6, 2020 21:40
-
-
Save jcvenegas/8e0279d55b8d1bfed3935054cec1e5ee to your computer and use it in GitHub Desktop.
Golang: Get stack printed via logrus (useful for logging in syslog)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Kata runtime example: | |
// sudo journalctl -t kata-runtime -o json -f | jq .MESSAGE | grep DEBUG --color | |
import "runtime/debug" | |
func stackLogger(logger logrus.Entry) { | |
stack_bytes := debug.Stack() | |
stack := string(stack_bytes) | |
for _, l := range strings.Split(stack, "\n") { | |
logger.Warnf("DEBUG -> %s", l) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment