Skip to content
Permalink
Browse files

add logs.{stdout,stderr} for configuring log levels. Closes #565

  • Loading branch information...
tj committed Jan 31, 2018
1 parent 9de01b0 commit 50ca13796c1f3ce6ae2079072c07bb259030ab74
Showing with 53 additions and 2 deletions.
  1. +5 −0 config/config.go
  2. +19 −0 config/logs.go
  3. +17 −0 docs/04-configuration.md
  4. +12 −2 http/relay/relay.go
@@ -142,6 +142,11 @@ func (c *Config) Default() error {
return errors.Wrap(err, ".dns")
}

// default .logs
if err := c.Logs.Default(); err != nil {
return errors.Wrap(err, ".logs")
}

// default .inject
if err := c.Inject.Default(); err != nil {
return errors.Wrap(err, ".inject")
@@ -4,4 +4,23 @@ package config
type Logs struct {
// Disable json log output.
Disable bool `json:"disable"`

// Stdout default log level.
Stdout string `json:"stdout"`

// Stderr default log level.
Stderr string `json:"stderr"`
}

// Default implementation.
func (l *Logs) Default() error {
if l.Stdout == "" {
l.Stdout = "info"
}

if l.Stderr == "" {
l.Stderr = "error"
}

return nil
}
@@ -648,6 +648,23 @@ For example you may want to override `proxy.command` for development, which is t
}
```

## Logs

By default Up treats stdout as `info` level logs, and stderr as `error` level. If your logger uses stderr, such as Node's `debug()` module and you'd like to change this behaviour you may override these levels:

```json
{
"name": "app",
"environment": {
"DEBUG": "myapp"
},
"logs": {
"stdout": "info",
"stderr": "info"
}
}
```

## Ignoring Files

Up supports gitignore style pattern matching for omitting files from deployment. The following files are loaded in sequence:
@@ -86,14 +86,24 @@ type Proxy struct {
// number of concurrent processes executing, and prevent exhausting
// the ulimits of the host OS.
func New(c *up.Config) (http.Handler, error) {
stdout, err := log.ParseLevel(c.Logs.Stdout)
if err != nil {
return nil, errors.Wrap(err, "invalid stdout error level")
}

stderr, err := log.ParseLevel(c.Logs.Stderr)
if err != nil {
return nil, errors.Wrap(err, "invalid stdout error level")
}

p := &Proxy{
config: c,
cmdCleanup: make(chan *exec.Cmd, 3),
maxRetries: c.Proxy.Backoff.Attempts,
timeout: time.Duration(c.Proxy.Timeout) * time.Second,
shutdownTimeout: time.Duration(c.Proxy.ShutdownTimeout) * time.Second,
stdout: writer.New(log.InfoLevel, ctx),
stderr: writer.New(log.ErrorLevel, ctx),
stdout: writer.New(stdout, ctx),
stderr: writer.New(stderr, ctx),
}

defer p.flushLogs()

0 comments on commit 50ca137

Please sign in to comment.
You can’t perform that action at this time.