refactor: move all logging functions to their own file
This commit is contained in:
committed by
Michael Hobbs
parent
9d287d0a5d
commit
04cd5eeb91
@@ -93,13 +93,6 @@ func MustGetEnv(key string) string {
|
|||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogFail is the failure log formatter
|
|
||||||
// prints text to stderr and exits with status 1
|
|
||||||
func LogFail(text string) {
|
|
||||||
fmt.Fprintln(os.Stderr, fmt.Sprintf("FAILED: %s", text))
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetDeployingAppImageName returns deploying image identifier for a given app, tag tuple. validate if tag is presented
|
// GetDeployingAppImageName returns deploying image identifier for a given app, tag tuple. validate if tag is presented
|
||||||
func GetDeployingAppImageName(appName, imageTag, imageRepo string) (imageName string) {
|
func GetDeployingAppImageName(appName, imageTag, imageRepo string) (imageName string) {
|
||||||
if appName == "" {
|
if appName == "" {
|
||||||
@@ -311,35 +304,6 @@ func IsImageHerokuishBased(image string) bool {
|
|||||||
return dockerCmd.Execute()
|
return dockerCmd.Execute()
|
||||||
}
|
}
|
||||||
|
|
||||||
// LogInfo1 is the info1 header formatter
|
|
||||||
func LogInfo1(text string) {
|
|
||||||
fmt.Fprintln(os.Stdout, fmt.Sprintf("-----> %s", text))
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogInfo1Quiet is the info1 header formatter (with quiet option)
|
|
||||||
func LogInfo1Quiet(text string) {
|
|
||||||
if os.Getenv("DOKKU_QUIET_OUTPUT") != "" {
|
|
||||||
LogInfo1(text)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogInfo2 is the info2 header formatter
|
|
||||||
func LogInfo2(text string) {
|
|
||||||
fmt.Fprintln(os.Stdout, fmt.Sprintf("=====> %s", text))
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogInfo2Quiet is the info2 header formatter (with quiet option)
|
|
||||||
func LogInfo2Quiet(text string) {
|
|
||||||
if os.Getenv("DOKKU_QUIET_OUTPUT") != "" {
|
|
||||||
LogInfo2(text)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// LogWarn is the warning log formatter
|
|
||||||
func LogWarn(text string) {
|
|
||||||
fmt.Fprintln(os.Stderr, fmt.Sprintf(" ! %s", text))
|
|
||||||
}
|
|
||||||
|
|
||||||
// ReadFirstLine gets the first line of a file that has contents and returns it
|
// ReadFirstLine gets the first line of a file that has contents and returns it
|
||||||
// if there are no contents, an empty string is returned
|
// if there are no contents, an empty string is returned
|
||||||
// will also return an empty string if the file does not exist
|
// will also return an empty string if the file does not exist
|
||||||
@@ -362,7 +326,6 @@ func ReadFirstLine(filename string) string {
|
|||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// StripInlineComments removes bash-style comment from input line
|
// StripInlineComments removes bash-style comment from input line
|
||||||
|
|||||||
42
plugins/common/log.go
Normal file
42
plugins/common/log.go
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package common
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LogFail is the failure log formatter
|
||||||
|
// prints text to stderr and exits with status 1
|
||||||
|
func LogFail(text string) {
|
||||||
|
fmt.Fprintln(os.Stderr, fmt.Sprintf("FAILED: %s", text))
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogInfo1 is the info1 header formatter
|
||||||
|
func LogInfo1(text string) {
|
||||||
|
fmt.Fprintln(os.Stdout, fmt.Sprintf("-----> %s", text))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogInfo1Quiet is the info1 header formatter (with quiet option)
|
||||||
|
func LogInfo1Quiet(text string) {
|
||||||
|
if os.Getenv("DOKKU_QUIET_OUTPUT") != "" {
|
||||||
|
LogInfo1(text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogInfo2 is the info2 header formatter
|
||||||
|
func LogInfo2(text string) {
|
||||||
|
fmt.Fprintln(os.Stdout, fmt.Sprintf("=====> %s", text))
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogInfo2Quiet is the info2 header formatter (with quiet option)
|
||||||
|
func LogInfo2Quiet(text string) {
|
||||||
|
if os.Getenv("DOKKU_QUIET_OUTPUT") != "" {
|
||||||
|
LogInfo2(text)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogWarn is the warning log formatter
|
||||||
|
func LogWarn(text string) {
|
||||||
|
fmt.Fprintln(os.Stderr, fmt.Sprintf(" ! %s", text))
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user