mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-23 00:39:13 +02:00
add in-built logging support for a better dev experience
This commit is contained in:
29
vendor/github.com/aybabtme/humanlog/docker_compose_handler.go
generated
vendored
Normal file
29
vendor/github.com/aybabtme/humanlog/docker_compose_handler.go
generated
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
package humanlog
|
||||
|
||||
import (
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// dcLogsPrefixRe parses out a prefix like 'web_1 | ' from docker-compose
|
||||
// The regex exists of five parts:
|
||||
// 1. An optional color terminal escape sequence
|
||||
// 2. The name of the service
|
||||
// 3. Any number of spaces, and a pipe symbol
|
||||
// 4. An optional color reset escape sequence
|
||||
// 5. The rest of the line
|
||||
var dcLogsPrefixRe = regexp.MustCompile("^(?:\x1b\\[\\d+m)?(?P<service_name>[a-zA-Z0-9._-]+)\\s+\\|(?:\x1b\\[0m)? (?P<rest_of_line>.*)$")
|
||||
|
||||
type handler interface {
|
||||
TryHandle([]byte) bool
|
||||
setField(key, val []byte)
|
||||
}
|
||||
|
||||
func tryDockerComposePrefix(d []byte, nextHandler handler) bool {
|
||||
if matches := dcLogsPrefixRe.FindSubmatch(d); matches != nil {
|
||||
if nextHandler.TryHandle(matches[2]) {
|
||||
nextHandler.setField([]byte(`service`), matches[1])
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
Reference in New Issue
Block a user