summaryrefslogtreecommitdiff
path: root/internal/config/client.go
blob: 3c2f7de7d0f06b2ae15225a8d8935aa74a8d09d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package config

import "github.com/mimecast/dtail/internal/color"

type remoteTermColors struct {
	DelimiterAttr color.Attribute
	DelimiterBg   color.BgColor
	DelimiterFg   color.FgColor
	RemoteAttr    color.Attribute
	RemoteBg      color.BgColor
	RemoteFg      color.FgColor
	CountAttr     color.Attribute
	CountBg       color.BgColor
	CountFg       color.FgColor
	HostnameAttr  color.Attribute
	HostnameBg    color.BgColor
	HostnameFg    color.FgColor
	IdAttr        color.Attribute
	IdBg          color.BgColor
	IdFg          color.FgColor
	StatsOkAttr   color.Attribute
	StatsOkBg     color.BgColor
	StatsOkFg     color.FgColor
	StatsWarnAttr color.Attribute
	StatsWarnBg   color.BgColor
	StatsWarnFg   color.FgColor
	TextAttr      color.Attribute
	TextBg        color.BgColor
	TextFg        color.FgColor
}

type clientTermColors struct {
	DelimiterAttr color.Attribute
	DelimiterBg   color.BgColor
	DelimiterFg   color.FgColor
	ClientAttr    color.Attribute
	ClientBg      color.BgColor
	ClientFg      color.FgColor
	HostnameAttr  color.Attribute
	HostnameBg    color.BgColor
	HostnameFg    color.FgColor
	TextAttr      color.Attribute
	TextBg        color.BgColor
	TextFg        color.FgColor
}

type serverTermColors struct {
	DelimiterAttr color.Attribute
	DelimiterBg   color.BgColor
	DelimiterFg   color.FgColor
	ServerAttr    color.Attribute
	ServerBg      color.BgColor
	ServerFg      color.FgColor
	HostnameAttr  color.Attribute
	HostnameBg    color.BgColor
	HostnameFg    color.FgColor
	TextAttr      color.Attribute
	TextBg        color.BgColor
	TextFg        color.FgColor
}

type commonTermColors struct {
	SeverityErrorAttr color.Attribute
	SeverityErrorBg   color.BgColor
	SeverityErrorFg   color.FgColor
	SeverityFatalAttr color.Attribute
	SeverityFatalBg   color.BgColor
	SeverityFatalFg   color.FgColor
	SeverityWarnAttr  color.Attribute
	SeverityWarnBg    color.BgColor
	SeverityWarnFg    color.FgColor
}

type termColors struct {
	Remote remoteTermColors
	Client clientTermColors
	Server serverTermColors
	Common commonTermColors
}

// ClientConfig represents a DTail client configuration (empty as of now as there
// are no available config options yet, but that may changes in the future).
type ClientConfig struct {
	TermColorsEnable bool
	TermColors       termColors `json:",omitempty"`
}

// Create a new default client configuration.
func newDefaultClientConfig() *ClientConfig {
	return &ClientConfig{
		TermColorsEnable: true,
		TermColors: termColors{
			Remote: remoteTermColors{
				DelimiterAttr: color.AttrDim,
				DelimiterBg:   color.BgBlue,
				DelimiterFg:   color.FgCyan,
				RemoteAttr:    color.AttrDim,
				RemoteBg:      color.BgBlue,
				RemoteFg:      color.FgWhite,
				CountAttr:     color.AttrDim,
				CountBg:       color.BgBlue,
				CountFg:       color.FgWhite,
				HostnameAttr:  color.AttrBold,
				HostnameBg:    color.BgBlue,
				HostnameFg:    color.FgWhite,
				IdAttr:        color.AttrDim,
				IdBg:          color.BgBlue,
				IdFg:          color.FgWhite,
				StatsOkAttr:   color.AttrNone,
				StatsOkBg:     color.BgGreen,
				StatsOkFg:     color.FgBlack,
				StatsWarnAttr: color.AttrNone,
				StatsWarnBg:   color.BgRed,
				StatsWarnFg:   color.FgWhite,
				TextAttr:      color.AttrNone,
				TextBg:        color.BgBlack,
				TextFg:        color.FgWhite,
			},
			Client: clientTermColors{
				DelimiterAttr: color.AttrDim,
				DelimiterBg:   color.BgYellow,
				DelimiterFg:   color.FgBlack,
				ClientAttr:    color.AttrDim,
				ClientBg:      color.BgYellow,
				ClientFg:      color.FgBlack,
				HostnameAttr:  color.AttrDim,
				HostnameBg:    color.BgYellow,
				HostnameFg:    color.FgBlack,
				TextAttr:      color.AttrNone,
				TextBg:        color.BgBlack,
				TextFg:        color.FgWhite,
			},
			Server: serverTermColors{
				DelimiterAttr: color.AttrDim,
				DelimiterBg:   color.BgCyan,
				DelimiterFg:   color.FgBlack,
				ServerAttr:    color.AttrDim,
				ServerBg:      color.BgCyan,
				ServerFg:      color.FgBlack,
				HostnameAttr:  color.AttrBold,
				HostnameBg:    color.BgCyan,
				HostnameFg:    color.FgBlack,
				TextAttr:      color.AttrNone,
				TextBg:        color.BgCyan,
				TextFg:        color.FgBlack,
			},
			Common: commonTermColors{
				SeverityErrorAttr: color.AttrBold,
				SeverityErrorBg:   color.BgRed,
				SeverityErrorFg:   color.FgWhite,
				SeverityFatalAttr: color.AttrBlink,
				SeverityFatalBg:   color.BgRed,
				SeverityFatalFg:   color.FgWhite,
				SeverityWarnAttr:  color.AttrBold,
				SeverityWarnBg:    color.BgBlack,
				SeverityWarnFg:    color.FgWhite,
			},
		},
	}
}