Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "local" log driver #37092

Merged
merged 4 commits into from Aug 20, 2018
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+1,579 −109
Diff settings

Always

Just for now

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -5,4 +5,12 @@ message LogEntry {
int64 time_nano = 2;
bytes line = 3;
bool partial = 4;
PartialLogEntryMetadata partial_log_metadata = 5;
}

message PartialLogEntryMetadata {
bool last = 1;
string id = 2;
int32 ordinal = 3;
}

Copy path View file
@@ -22,7 +22,9 @@ import (
"github.com/docker/docker/daemon/exec"
"github.com/docker/docker/daemon/logger"
"github.com/docker/docker/daemon/logger/jsonfilelog"
"github.com/docker/docker/daemon/logger/local"
"github.com/docker/docker/daemon/network"
"github.com/docker/docker/errdefs"
"github.com/docker/docker/image"
"github.com/docker/docker/layer"
"github.com/docker/docker/pkg/containerfs"
@@ -375,13 +377,27 @@ func (container *Container) StartLogger() (logger.Logger, error) {
}

// Set logging file for "json-logger"
if cfg.Type == jsonfilelog.Name {
// TODO(@cpuguy83): Setup here based on log driver is a little weird.
switch cfg.Type {
case jsonfilelog.Name:
info.LogPath, err = container.GetRootResourcePath(fmt.Sprintf("%s-json.log", container.ID))
if err != nil {
return nil, err
}

container.LogPath = info.LogPath
case local.Name:
// Do not set container.LogPath for the local driver
// This would expose the value to the API, which should not be done as it means
// that the log file implementation would become a stable API that cannot change.
logDir, err := container.GetRootResourcePath("local-logs")
if err != nil {
return nil, err
}
if err := os.MkdirAll(logDir, 0700); err != nil {
return nil, errdefs.System(errors.Wrap(err, "error creating local logs dir"))
}
info.LogPath = filepath.Join(logDir, "container.log")

This comment has been minimized.

Copy link
@vdemeester

vdemeester Jul 9, 2018

Member

why don't we set container.LogPath here too ? 🤔

This comment has been minimized.

Copy link
@cpuguy83

cpuguy83 Jul 9, 2018

Author Contributor

We don't want to expose this to users.

This comment has been minimized.

Copy link
@thaJeztah

thaJeztah Jul 11, 2018

Member

Can you add a comment about that? Just in case someone decides to add it, and doesn't know about this history.

}

l, err := initDriver(info)
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.