podman

Форк
0
58 строк · 1.6 Кб
1
package docker
2

3
import (
4
	"context"
5
	"io"
6
	"net/http"
7
	"time"
8
)
9

10
// LogsOptions represents the set of options used when getting logs from a
11
// container.
12
//
13
// See https://goo.gl/krK0ZH for more details.
14
type LogsOptions struct {
15
	Context           context.Context
16
	Container         string        `qs:"-"`
17
	OutputStream      io.Writer     `qs:"-"`
18
	ErrorStream       io.Writer     `qs:"-"`
19
	InactivityTimeout time.Duration `qs:"-"`
20
	Tail              string
21

22
	Since      int64
23
	Follow     bool
24
	Stdout     bool
25
	Stderr     bool
26
	Timestamps bool
27

28
	// Use raw terminal? Usually true when the container contains a TTY.
29
	RawTerminal bool `qs:"-"`
30
}
31

32
// Logs gets stdout and stderr logs from the specified container.
33
//
34
// When LogsOptions.RawTerminal is set to false, go-dockerclient will multiplex
35
// the streams and send the containers stdout to LogsOptions.OutputStream, and
36
// stderr to LogsOptions.ErrorStream.
37
//
38
// When LogsOptions.RawTerminal is true, callers will get the raw stream on
39
// LogsOptions.OutputStream. The caller can use libraries such as dlog
40
// (github.com/ahmetalpbalkan/dlog).
41
//
42
// See https://goo.gl/krK0ZH for more details.
43
func (c *Client) Logs(opts LogsOptions) error {
44
	if opts.Container == "" {
45
		return &NoSuchContainer{ID: opts.Container}
46
	}
47
	if opts.Tail == "" {
48
		opts.Tail = "all"
49
	}
50
	path := "/containers/" + opts.Container + "/logs?" + queryString(opts)
51
	return c.stream(http.MethodGet, path, streamOptions{
52
		setRawTerminal:    opts.RawTerminal,
53
		stdout:            opts.OutputStream,
54
		stderr:            opts.ErrorStream,
55
		inactivityTimeout: opts.InactivityTimeout,
56
		context:           opts.Context,
57
	})
58
}
59

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.