Created
March 22, 2020 11:39
-
-
Save KanybekMomukeyev/83582f64eac62fe4decd4b18921a5d24 to your computer and use it in GitHub Desktop.
Example docker volume
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
var logrusIn = logrus.New() | |
var logrusOut = logrus.New() | |
func init() { | |
logrusIn.SetFormatter(&logrus.JSONFormatter{}) | |
logrusIn.SetOutput(os.Stdout) | |
logrusIn.SetLevel(logrus.InfoLevel) | |
logrusOut.SetFormatter(&logrus.JSONFormatter{}) | |
logrusOut.SetOutput(os.Stdout) | |
logrusOut.SetLevel(logrus.InfoLevel) | |
} | |
func main() { | |
// exampleClient() | |
// telebotEx() | |
// app := googleService() | |
// sendToToken1(app) | |
// sendAll(app) | |
echoTest() | |
} | |
func echoTest() { | |
fmt.Printf("\n -- ENTER MAIN LOG HELLO WORLD --\n") | |
fmt.Printf("\nENV API_LOGRUS_PATH1 %s\n", os.Getenv("API_LOGRUS_PATH1")) | |
fmt.Printf("\nENV API_LOGRUS_PATH2 %s\n", os.Getenv("API_LOGRUS_PATH2")) | |
files, err := ioutil.ReadDir(".") | |
fmt.Printf("\n -- DIR LIST START --\n") | |
if err != nil { | |
log.Fatal(err) | |
} | |
for _, f := range files { | |
fmt.Printf("\nfileName %s\n", f.Name()) | |
} | |
fmt.Printf("\n -- DIR LIST END --\n") | |
// --------------------------------------------------------------------------------------- | |
logrusIn.Out = os.Stdout | |
file1, err := os.OpenFile(os.Getenv("API_LOGRUS_PATH1"), os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) | |
if err == nil { | |
logrusIn.Out = file1 | |
} else { | |
logrusIn.Info("Failed to log to file, using default stderr") | |
} | |
defer file1.Close() | |
// --------------------------------------------------------------------------------------- | |
logrusOut.Out = os.Stdout | |
file2, err := os.OpenFile(os.Getenv("API_LOGRUS_PATH2"), os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) | |
if err == nil { | |
logrusOut.Out = file2 | |
} else { | |
logrusOut.Info("Failed to log to file, using default stderr") | |
} | |
defer file2.Close() | |
// --------------------------------------------------------------------------------------- | |
// Echo instance | |
e := echo.New() | |
// Middleware | |
e.Use(middleware.Logger()) | |
e.Use(middleware.Recover()) | |
// Routes | |
e.GET("/", hello) | |
// Start server | |
e.Logger.Fatal(e.Start(":4444")) | |
} | |
// Handler | |
func hello(c echo.Context) error { | |
iFoo := 209 | |
strFoo := foo.ConvertInt2String(iFoo) | |
fmt.Printf("\nfoo.ConvertInt2String %d : %s\n", iFoo, strFoo) | |
strBar := "28" | |
iBar, _ := bar.ConvertString2Int(strBar) | |
fmt.Printf("\nbar.ConvertString2Int %s : %d\n", strBar, iBar) | |
logrusIn.WithFields(logrus.Fields{ | |
"CREATE PAYM ORDER REQUEST_BODY111111": "string(jsonValue)", | |
}).Info("createPaymentOrder") | |
logrusOut.WithFields(logrus.Fields{ | |
"CREATE PAYM ORDER REQUEST_BODY222222": "string(jsonValue)", | |
}).Info("createPaymentOrder") | |
return c.String(http.StatusOK, "Hello, World Go modules!") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment