Browse Source

En cours de développement

master
mls-361 9 months ago
parent
commit
3f57d89d18
  1. 12
      cmd/main.go
  2. 9
      internal/logger/logger.go

12
cmd/main.go

@ -40,7 +40,7 @@ func init() {
rand.Seed(time.Now().UnixNano())
}
func buildComponents(args []string, ccs *components.Components) error {
func buildComponents(cliApp bool, ccs *components.Components) error {
var err error
ccs.Config, err = config.Load(ccs)
@ -48,7 +48,7 @@ func buildComponents(args []string, ccs *components.Components) error {
return errors.WithMessage(err, "config") ///////////////////////////////////////////////////////////////////////
}
ccs.Logger, err = logger.Build(ccs)
ccs.Logger, err = logger.Build(cliApp, ccs)
if err != nil {
return errors.WithMessage(err, "logger") ///////////////////////////////////////////////////////////////////////
}
@ -68,7 +68,7 @@ func buildComponents(args []string, ccs *components.Components) error {
return errors.WithMessage(err, "model") ////////////////////////////////////////////////////////////////////////
}
if len(args) != 0 {
if cliApp {
return nil
}
@ -113,6 +113,8 @@ func waitEnd(server components.Server) (*sync.WaitGroup, chan struct{}) {
}
func run(args []string) error {
cliApp := len(args) != 0
app := application.New("armen", _version, _builtAt)
if err := app.Initialize(); err != nil {
return app.OnError(err)
@ -122,7 +124,7 @@ func run(args []string) error {
defer ccs.Shutdown()
if err := buildComponents(args, ccs); err != nil {
if err := buildComponents(cliApp, ccs); err != nil {
if ccs.Logger != nil {
ccs.Logger.Fatal( //::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"Components build error",
@ -133,7 +135,7 @@ func run(args []string) error {
return app.OnError(err)
}
if len(args) != 0 {
if cliApp {
return app.OnError(cli.Run(args, ccs))
}

9
internal/logger/logger.go

@ -15,7 +15,7 @@ import (
)
// Build AFAIRE.
func Build(ccs *components.Components) (components.Logger, error) {
func Build(cliApp bool, ccs *components.Components) (components.Logger, error) {
app := ccs.Application
cfg := ccs.Config.Logger()
@ -46,8 +46,13 @@ func Build(ccs *components.Components) (components.Logger, error) {
return nil, err
}
title := "APP"
if cliApp {
title = "CLI"
}
logger.Info( //:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
"APP",
title,
"id", app.ID(),
"name", app.Name(),
"version", app.Version(),

Loading…
Cancel
Save