Commit ·
9fb7635
1
Parent(s): 832b052
removed csv
Browse files- data/train/data.csv +0 -525
data/train/data.csv
DELETED
|
@@ -1,525 +0,0 @@
|
|
| 1 |
-
highlights,article,id
|
| 2 |
-
"[""LOCALHOST_IP"", ""CASSANDRA_SEEDS"", ""CASSANDRA_PORT"", ""MYSQL_SEEDS"", ""MYSQL_PORT"", ""ES_SEEDS"", ""ES_PORT"", ""ES_VERSION"", ""POSTGRES_SEEDS"", ""POSTGRES_PORT""]","// The MIT License
|
| 3 |
-
//
|
| 4 |
-
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
|
| 5 |
-
//
|
| 6 |
-
// Copyright (c) 2020 Uber Technologies, Inc.
|
| 7 |
-
//
|
| 8 |
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 9 |
-
// of this software and associated documentation files (the ""Software""), to deal
|
| 10 |
-
// in the Software without restriction, including without limitation the rights
|
| 11 |
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 12 |
-
// copies of the Software, and to permit persons to whom the Software is
|
| 13 |
-
// furnished to do so, subject to the following conditions:
|
| 14 |
-
//
|
| 15 |
-
// The above copyright notice and this permission notice shall be included in
|
| 16 |
-
// all copies or substantial portions of the Software.
|
| 17 |
-
//
|
| 18 |
-
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 19 |
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 20 |
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 21 |
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 22 |
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 23 |
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 24 |
-
// THE SOFTWARE.
|
| 25 |
-
|
| 26 |
-
package environment
|
| 27 |
-
|
| 28 |
-
import (
|
| 29 |
-
""fmt""
|
| 30 |
-
""net""
|
| 31 |
-
""os""
|
| 32 |
-
""strconv""
|
| 33 |
-
)
|
| 34 |
-
|
| 35 |
-
const (
|
| 36 |
-
// LocalhostIP default localhost
|
| 37 |
-
LocalhostIP = ""LOCALHOST_IP""
|
| 38 |
-
// Localhost default hostname
|
| 39 |
-
LocalhostIPDefault = ""127.0.0.1""
|
| 40 |
-
|
| 41 |
-
// CassandraSeeds env
|
| 42 |
-
CassandraSeeds = ""CASSANDRA_SEEDS""
|
| 43 |
-
// CassandraPort env
|
| 44 |
-
CassandraPort = ""CASSANDRA_PORT""
|
| 45 |
-
// CassandraDefaultPort Cassandra default port
|
| 46 |
-
CassandraDefaultPort = 9042
|
| 47 |
-
|
| 48 |
-
// MySQLSeeds env
|
| 49 |
-
MySQLSeeds = ""MYSQL_SEEDS""
|
| 50 |
-
// MySQLPort env
|
| 51 |
-
MySQLPort = ""MYSQL_PORT""
|
| 52 |
-
// MySQLDefaultPort MySQL default port
|
| 53 |
-
MySQLDefaultPort = 3306
|
| 54 |
-
|
| 55 |
-
// ESSeeds env
|
| 56 |
-
ESSeeds = ""ES_SEEDS""
|
| 57 |
-
// ESPort env
|
| 58 |
-
ESPort = ""ES_PORT""
|
| 59 |
-
// ESDefaultPort ES default port
|
| 60 |
-
ESDefaultPort = 9200
|
| 61 |
-
// ESVersion is the ElasticSearch version
|
| 62 |
-
ESVersion = ""ES_VERSION""
|
| 63 |
-
// ESDefaultVersion is the default version
|
| 64 |
-
ESDefaultVersion = ""v7""
|
| 65 |
-
|
| 66 |
-
// PostgresSeeds env
|
| 67 |
-
PostgresSeeds = ""POSTGRES_SEEDS""
|
| 68 |
-
// PostgresPort env
|
| 69 |
-
PostgresPort = ""POSTGRES_PORT""
|
| 70 |
-
// PostgresDefaultPort Postgres default port
|
| 71 |
-
PostgresDefaultPort = 5432
|
| 72 |
-
)
|
| 73 |
-
|
| 74 |
-
type varSpec struct {
|
| 75 |
-
name string
|
| 76 |
-
getDefault func() string
|
| 77 |
-
}
|
| 78 |
-
|
| 79 |
-
var envVars = []varSpec{
|
| 80 |
-
{
|
| 81 |
-
name: LocalhostIP,
|
| 82 |
-
getDefault: func() string { return lookupLocalhostIP(""localhost"") },
|
| 83 |
-
},
|
| 84 |
-
{
|
| 85 |
-
name: CassandraSeeds,
|
| 86 |
-
getDefault: GetLocalhostIP,
|
| 87 |
-
},
|
| 88 |
-
{
|
| 89 |
-
name: CassandraPort,
|
| 90 |
-
getDefault: func() string { return strconv.Itoa(CassandraDefaultPort) },
|
| 91 |
-
},
|
| 92 |
-
{
|
| 93 |
-
name: MySQLSeeds,
|
| 94 |
-
getDefault: GetLocalhostIP,
|
| 95 |
-
},
|
| 96 |
-
{
|
| 97 |
-
name: MySQLPort,
|
| 98 |
-
getDefault: func() string { return strconv.Itoa(MySQLDefaultPort) },
|
| 99 |
-
},
|
| 100 |
-
{
|
| 101 |
-
name: PostgresSeeds,
|
| 102 |
-
getDefault: GetLocalhostIP,
|
| 103 |
-
},
|
| 104 |
-
{
|
| 105 |
-
name: PostgresPort,
|
| 106 |
-
getDefault: func() string { return strconv.Itoa(PostgresDefaultPort) },
|
| 107 |
-
},
|
| 108 |
-
{
|
| 109 |
-
name: ESSeeds,
|
| 110 |
-
getDefault: GetLocalhostIP,
|
| 111 |
-
},
|
| 112 |
-
{
|
| 113 |
-
name: ESPort,
|
| 114 |
-
getDefault: func() string { return strconv.Itoa(ESDefaultPort) },
|
| 115 |
-
},
|
| 116 |
-
{
|
| 117 |
-
name: ESVersion,
|
| 118 |
-
getDefault: func() string { return ESDefaultVersion },
|
| 119 |
-
},
|
| 120 |
-
}
|
| 121 |
-
|
| 122 |
-
// SetupEnv setup the necessary env
|
| 123 |
-
func SetupEnv() {
|
| 124 |
-
for _, envVar := range envVars {
|
| 125 |
-
if os.Getenv(envVar.name) == """" {
|
| 126 |
-
if err := os.Setenv(envVar.name, envVar.getDefault()); err != nil {
|
| 127 |
-
panic(fmt.Sprintf(""error setting env var %s: %s"", envVar.name, err))
|
| 128 |
-
}
|
| 129 |
-
}
|
| 130 |
-
}
|
| 131 |
-
}
|
| 132 |
-
|
| 133 |
-
func lookupLocalhostIP(domain string) string {
|
| 134 |
-
// lookup localhost and favor the first ipv4 address
|
| 135 |
-
// unless there are only ipv6 addresses available
|
| 136 |
-
ips, err := net.LookupIP(domain)
|
| 137 |
-
if err != nil || len(ips) == 0 {
|
| 138 |
-
// fallback to default instead of error
|
| 139 |
-
return LocalhostIPDefault
|
| 140 |
-
}
|
| 141 |
-
var listenIp net.IP
|
| 142 |
-
for _, ip := range ips {
|
| 143 |
-
listenIp = ip
|
| 144 |
-
if listenIp.To4() != nil {
|
| 145 |
-
break
|
| 146 |
-
}
|
| 147 |
-
}
|
| 148 |
-
return listenIp.String()
|
| 149 |
-
}
|
| 150 |
-
|
| 151 |
-
// GetLocalhostIP returns the ip address of the localhost domain
|
| 152 |
-
func GetLocalhostIP() string {
|
| 153 |
-
localhostIP := os.Getenv(LocalhostIP)
|
| 154 |
-
ip := net.ParseIP(localhostIP)
|
| 155 |
-
if ip != nil {
|
| 156 |
-
// if localhost is an ip return it
|
| 157 |
-
return ip.String()
|
| 158 |
-
}
|
| 159 |
-
// otherwise, ignore the value and lookup `localhost`
|
| 160 |
-
return lookupLocalhostIP(""localhost"")
|
| 161 |
-
}
|
| 162 |
-
|
| 163 |
-
// GetCassandraAddress return the cassandra address
|
| 164 |
-
func GetCassandraAddress() string {
|
| 165 |
-
addr := os.Getenv(CassandraSeeds)
|
| 166 |
-
if addr == """" {
|
| 167 |
-
addr = GetLocalhostIP()
|
| 168 |
-
}
|
| 169 |
-
return addr
|
| 170 |
-
}
|
| 171 |
-
|
| 172 |
-
// GetCassandraPort return the cassandra port
|
| 173 |
-
func GetCassandraPort() int {
|
| 174 |
-
port := os.Getenv(CassandraPort)
|
| 175 |
-
if port == """" {
|
| 176 |
-
return CassandraDefaultPort
|
| 177 |
-
}
|
| 178 |
-
p, err := strconv.Atoi(port)
|
| 179 |
-
if err != nil {
|
| 180 |
-
panic(fmt.Sprintf(""error getting env %v"", CassandraPort))
|
| 181 |
-
}
|
| 182 |
-
return p
|
| 183 |
-
}
|
| 184 |
-
|
| 185 |
-
// GetMySQLAddress return the cassandra address
|
| 186 |
-
func GetMySQLAddress() string {
|
| 187 |
-
addr := os.Getenv(MySQLSeeds)
|
| 188 |
-
if addr == """" {
|
| 189 |
-
addr = GetLocalhostIP()
|
| 190 |
-
}
|
| 191 |
-
return addr
|
| 192 |
-
}
|
| 193 |
-
|
| 194 |
-
// GetMySQLPort return the MySQL port
|
| 195 |
-
func GetMySQLPort() int {
|
| 196 |
-
port := os.Getenv(MySQLPort)
|
| 197 |
-
if port == """" {
|
| 198 |
-
return MySQLDefaultPort
|
| 199 |
-
}
|
| 200 |
-
p, err := strconv.Atoi(port)
|
| 201 |
-
if err != nil {
|
| 202 |
-
panic(fmt.Sprintf(""error getting env %v"", MySQLPort))
|
| 203 |
-
}
|
| 204 |
-
return p
|
| 205 |
-
}
|
| 206 |
-
|
| 207 |
-
// GetPostgreSQLAddress return the cassandra address
|
| 208 |
-
func GetPostgreSQLAddress() string {
|
| 209 |
-
addr := os.Getenv(PostgresSeeds)
|
| 210 |
-
if addr == """" {
|
| 211 |
-
addr = GetLocalhostIP()
|
| 212 |
-
}
|
| 213 |
-
return addr
|
| 214 |
-
}
|
| 215 |
-
|
| 216 |
-
// GetPostgreSQLPort return the Postgres port
|
| 217 |
-
func GetPostgreSQLPort() int {
|
| 218 |
-
port := os.Getenv(PostgresPort)
|
| 219 |
-
if port == """" {
|
| 220 |
-
return PostgresDefaultPort
|
| 221 |
-
}
|
| 222 |
-
p, err := strconv.Atoi(port)
|
| 223 |
-
if err != nil {
|
| 224 |
-
panic(fmt.Sprintf(""error getting env %v"", PostgresPort))
|
| 225 |
-
}
|
| 226 |
-
return p
|
| 227 |
-
}
|
| 228 |
-
",8da30a84-46e2-434a-9df9-4fc9ab89a897
|
| 229 |
-
"[""TEMPORAL_TEST_LOG_FORMAT"", ""TEMPORAL_TEST_LOG_LEVEL""]","// The MIT License
|
| 230 |
-
//
|
| 231 |
-
// Copyright (c) 2020 Temporal Technologies Inc. All rights reserved.
|
| 232 |
-
//
|
| 233 |
-
// Copyright (c) 2020 Uber Technologies, Inc.
|
| 234 |
-
//
|
| 235 |
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 236 |
-
// of this software and associated documentation files (the ""Software""), to deal
|
| 237 |
-
// in the Software without restriction, including without limitation the rights
|
| 238 |
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 239 |
-
// copies of the Software, and to permit persons to whom the Software is
|
| 240 |
-
// furnished to do so, subject to the following conditions:
|
| 241 |
-
//
|
| 242 |
-
// The above copyright notice and this permission notice shall be included in
|
| 243 |
-
// all copies or substantial portions of the Software.
|
| 244 |
-
//
|
| 245 |
-
// THE SOFTWARE IS PROVIDED ""AS IS"", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 246 |
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 247 |
-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 248 |
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 249 |
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 250 |
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
| 251 |
-
// THE SOFTWARE.
|
| 252 |
-
|
| 253 |
-
package log
|
| 254 |
-
|
| 255 |
-
import (
|
| 256 |
-
""os""
|
| 257 |
-
""path/filepath""
|
| 258 |
-
""runtime""
|
| 259 |
-
""strconv""
|
| 260 |
-
""strings""
|
| 261 |
-
|
| 262 |
-
""go.uber.org/zap""
|
| 263 |
-
""go.uber.org/zap/zapcore""
|
| 264 |
-
|
| 265 |
-
""go.temporal.io/server/common/log/tag""
|
| 266 |
-
)
|
| 267 |
-
|
| 268 |
-
const (
|
| 269 |
-
skipForZapLogger = 3
|
| 270 |
-
// we put a default message when it is empty so that the log can be searchable/filterable
|
| 271 |
-
defaultMsgForEmpty = ""none""
|
| 272 |
-
testLogFormatEnvVar = ""TEMPORAL_TEST_LOG_FORMAT"" // set to ""json"" for json logs in tests
|
| 273 |
-
testLogLevelEnvVar = ""TEMPORAL_TEST_LOG_LEVEL"" // set to ""debug"" for debug level logs in tests
|
| 274 |
-
)
|
| 275 |
-
|
| 276 |
-
type (
|
| 277 |
-
// zapLogger is logger backed up by zap.Logger.
|
| 278 |
-
zapLogger struct {
|
| 279 |
-
zl *zap.Logger
|
| 280 |
-
skip int
|
| 281 |
-
}
|
| 282 |
-
)
|
| 283 |
-
|
| 284 |
-
var _ Logger = (*zapLogger)(nil)
|
| 285 |
-
|
| 286 |
-
// NewTestLogger returns a logger for tests
|
| 287 |
-
func NewTestLogger() *zapLogger {
|
| 288 |
-
format := os.Getenv(testLogFormatEnvVar)
|
| 289 |
-
if format == """" {
|
| 290 |
-
format = ""console""
|
| 291 |
-
}
|
| 292 |
-
|
| 293 |
-
logger := BuildZapLogger(Config{
|
| 294 |
-
Level: os.Getenv(testLogLevelEnvVar),
|
| 295 |
-
Format: format,
|
| 296 |
-
Development: true,
|
| 297 |
-
})
|
| 298 |
-
|
| 299 |
-
// Don't include stack traces for warnings during tests. Only include them for logs with level error and above.
|
| 300 |
-
logger = logger.WithOptions(zap.AddStacktrace(zap.ErrorLevel))
|
| 301 |
-
|
| 302 |
-
return NewZapLogger(logger)
|
| 303 |
-
}
|
| 304 |
-
|
| 305 |
-
// NewCLILogger returns a logger at debug level and log into STDERR for logging from within CLI tools
|
| 306 |
-
func NewCLILogger() *zapLogger {
|
| 307 |
-
return NewZapLogger(buildCLIZapLogger())
|
| 308 |
-
}
|
| 309 |
-
|
| 310 |
-
// NewZapLogger returns a new zap based logger from zap.Logger
|
| 311 |
-
func NewZapLogger(zl *zap.Logger) *zapLogger {
|
| 312 |
-
return &zapLogger{
|
| 313 |
-
zl: zl,
|
| 314 |
-
skip: skipForZapLogger,
|
| 315 |
-
}
|
| 316 |
-
}
|
| 317 |
-
|
| 318 |
-
// BuildZapLogger builds and returns a new zap.Logger for this logging configuration
|
| 319 |
-
func BuildZapLogger(cfg Config) *zap.Logger {
|
| 320 |
-
return buildZapLogger(cfg, true)
|
| 321 |
-
}
|
| 322 |
-
|
| 323 |
-
func caller(skip int) string {
|
| 324 |
-
_, path, line, ok := runtime.Caller(skip)
|
| 325 |
-
if !ok {
|
| 326 |
-
return """"
|
| 327 |
-
}
|
| 328 |
-
return filepath.Base(path) + "":"" + strconv.Itoa(line)
|
| 329 |
-
}
|
| 330 |
-
|
| 331 |
-
func (l *zapLogger) buildFieldsWithCallAt(tags []tag.Tag) []zap.Field {
|
| 332 |
-
fields := make([]zap.Field, len(tags)+1)
|
| 333 |
-
l.fillFields(tags, fields)
|
| 334 |
-
fields[len(fields)-1] = zap.String(tag.LoggingCallAtKey, caller(l.skip))
|
| 335 |
-
return fields
|
| 336 |
-
}
|
| 337 |
-
|
| 338 |
-
// fillFields fill fields parameter with fields read from tags. Optimized for performance.
|
| 339 |
-
func (l *zapLogger) fillFields(tags []tag.Tag, fields []zap.Field) {
|
| 340 |
-
for i, t := range tags {
|
| 341 |
-
if zt, ok := t.(tag.ZapTag); ok {
|
| 342 |
-
fields[i] = zt.Field()
|
| 343 |
-
} else {
|
| 344 |
-
fields[i] = zap.Any(t.Key(), t.Value())
|
| 345 |
-
}
|
| 346 |
-
}
|
| 347 |
-
}
|
| 348 |
-
|
| 349 |
-
func setDefaultMsg(msg string) string {
|
| 350 |
-
if msg == """" {
|
| 351 |
-
return defaultMsgForEmpty
|
| 352 |
-
}
|
| 353 |
-
return msg
|
| 354 |
-
}
|
| 355 |
-
|
| 356 |
-
func (l *zapLogger) Debug(msg string, tags ...tag.Tag) {
|
| 357 |
-
if l.zl.Core().Enabled(zap.DebugLevel) {
|
| 358 |
-
msg = setDefaultMsg(msg)
|
| 359 |
-
fields := l.buildFieldsWithCallAt(tags)
|
| 360 |
-
l.zl.Debug(msg, fields...)
|
| 361 |
-
}
|
| 362 |
-
}
|
| 363 |
-
|
| 364 |
-
func (l *zapLogger) Info(msg string, tags ...tag.Tag) {
|
| 365 |
-
if l.zl.Core().Enabled(zap.InfoLevel) {
|
| 366 |
-
msg = setDefaultMsg(msg)
|
| 367 |
-
fields := l.buildFieldsWithCallAt(tags)
|
| 368 |
-
l.zl.Info(msg, fields...)
|
| 369 |
-
}
|
| 370 |
-
}
|
| 371 |
-
|
| 372 |
-
func (l *zapLogger) Warn(msg string, tags ...tag.Tag) {
|
| 373 |
-
if l.zl.Core().Enabled(zap.WarnLevel) {
|
| 374 |
-
msg = setDefaultMsg(msg)
|
| 375 |
-
fields := l.buildFieldsWithCallAt(tags)
|
| 376 |
-
l.zl.Warn(msg, fields...)
|
| 377 |
-
}
|
| 378 |
-
}
|
| 379 |
-
|
| 380 |
-
func (l *zapLogger) Error(msg string, tags ...tag.Tag) {
|
| 381 |
-
if l.zl.Core().Enabled(zap.ErrorLevel) {
|
| 382 |
-
msg = setDefaultMsg(msg)
|
| 383 |
-
fields := l.buildFieldsWithCallAt(tags)
|
| 384 |
-
l.zl.Error(msg, fields...)
|
| 385 |
-
}
|
| 386 |
-
}
|
| 387 |
-
|
| 388 |
-
func (l *zapLogger) DPanic(msg string, tags ...tag.Tag) {
|
| 389 |
-
if l.zl.Core().Enabled(zap.DPanicLevel) {
|
| 390 |
-
msg = setDefaultMsg(msg)
|
| 391 |
-
fields := l.buildFieldsWithCallAt(tags)
|
| 392 |
-
l.zl.DPanic(msg, fields...)
|
| 393 |
-
}
|
| 394 |
-
}
|
| 395 |
-
|
| 396 |
-
func (l *zapLogger) Panic(msg string, tags ...tag.Tag) {
|
| 397 |
-
if l.zl.Core().Enabled(zap.PanicLevel) {
|
| 398 |
-
msg = setDefaultMsg(msg)
|
| 399 |
-
fields := l.buildFieldsWithCallAt(tags)
|
| 400 |
-
l.zl.Panic(msg, fields...)
|
| 401 |
-
}
|
| 402 |
-
}
|
| 403 |
-
|
| 404 |
-
func (l *zapLogger) Fatal(msg string, tags ...tag.Tag) {
|
| 405 |
-
if l.zl.Core().Enabled(zap.FatalLevel) {
|
| 406 |
-
msg = setDefaultMsg(msg)
|
| 407 |
-
fields := l.buildFieldsWithCallAt(tags)
|
| 408 |
-
l.zl.Fatal(msg, fields...)
|
| 409 |
-
}
|
| 410 |
-
}
|
| 411 |
-
|
| 412 |
-
func (l *zapLogger) With(tags ...tag.Tag) Logger {
|
| 413 |
-
fields := make([]zap.Field, len(tags))
|
| 414 |
-
l.fillFields(tags, fields)
|
| 415 |
-
zl := l.zl.With(fields...)
|
| 416 |
-
return &zapLogger{
|
| 417 |
-
zl: zl,
|
| 418 |
-
skip: l.skip,
|
| 419 |
-
}
|
| 420 |
-
}
|
| 421 |
-
|
| 422 |
-
func (l *zapLogger) Skip(extraSkip int) Logger {
|
| 423 |
-
return &zapLogger{
|
| 424 |
-
zl: l.zl,
|
| 425 |
-
skip: l.skip + extraSkip,
|
| 426 |
-
}
|
| 427 |
-
}
|
| 428 |
-
|
| 429 |
-
func buildZapLogger(cfg Config, disableCaller bool) *zap.Logger {
|
| 430 |
-
encodeConfig := zapcore.EncoderConfig{
|
| 431 |
-
TimeKey: ""ts"",
|
| 432 |
-
LevelKey: ""level"",
|
| 433 |
-
NameKey: ""logger"",
|
| 434 |
-
CallerKey: zapcore.OmitKey, // we use our own caller
|
| 435 |
-
FunctionKey: zapcore.OmitKey,
|
| 436 |
-
MessageKey: ""msg"",
|
| 437 |
-
StacktraceKey: ""stacktrace"",
|
| 438 |
-
LineEnding: zapcore.DefaultLineEnding,
|
| 439 |
-
EncodeLevel: zapcore.LowercaseLevelEncoder,
|
| 440 |
-
EncodeTime: zapcore.ISO8601TimeEncoder,
|
| 441 |
-
EncodeDuration: zapcore.SecondsDurationEncoder,
|
| 442 |
-
EncodeCaller: zapcore.ShortCallerEncoder,
|
| 443 |
-
}
|
| 444 |
-
if disableCaller {
|
| 445 |
-
encodeConfig.CallerKey = zapcore.OmitKey
|
| 446 |
-
encodeConfig.EncodeCaller = nil
|
| 447 |
-
}
|
| 448 |
-
|
| 449 |
-
outputPath := ""stderr""
|
| 450 |
-
if len(cfg.OutputFile) > 0 {
|
| 451 |
-
outputPath = cfg.OutputFile
|
| 452 |
-
}
|
| 453 |
-
if cfg.Stdout {
|
| 454 |
-
outputPath = ""stdout""
|
| 455 |
-
}
|
| 456 |
-
encoding := ""json""
|
| 457 |
-
if cfg.Format == ""console"" {
|
| 458 |
-
encoding = ""console""
|
| 459 |
-
}
|
| 460 |
-
config := zap.Config{
|
| 461 |
-
Level: zap.NewAtomicLevelAt(parseZapLevel(cfg.Level)),
|
| 462 |
-
Development: cfg.Development,
|
| 463 |
-
Sampling: nil,
|
| 464 |
-
Encoding: encoding,
|
| 465 |
-
EncoderConfig: encodeConfig,
|
| 466 |
-
OutputPaths: []string{outputPath},
|
| 467 |
-
ErrorOutputPaths: []string{outputPath},
|
| 468 |
-
DisableCaller: disableCaller,
|
| 469 |
-
}
|
| 470 |
-
logger, _ := config.Build()
|
| 471 |
-
return logger
|
| 472 |
-
}
|
| 473 |
-
|
| 474 |
-
func buildCLIZapLogger() *zap.Logger {
|
| 475 |
-
encodeConfig := zapcore.EncoderConfig{
|
| 476 |
-
TimeKey: ""ts"",
|
| 477 |
-
LevelKey: ""level"",
|
| 478 |
-
NameKey: ""logger"",
|
| 479 |
-
CallerKey: zapcore.OmitKey, // we use our own caller
|
| 480 |
-
FunctionKey: zapcore.OmitKey,
|
| 481 |
-
MessageKey: ""msg"",
|
| 482 |
-
StacktraceKey: ""stacktrace"",
|
| 483 |
-
LineEnding: zapcore.DefaultLineEnding,
|
| 484 |
-
EncodeLevel: zapcore.CapitalColorLevelEncoder,
|
| 485 |
-
EncodeTime: zapcore.ISO8601TimeEncoder,
|
| 486 |
-
EncodeDuration: zapcore.SecondsDurationEncoder,
|
| 487 |
-
EncodeCaller: nil,
|
| 488 |
-
}
|
| 489 |
-
|
| 490 |
-
config := zap.Config{
|
| 491 |
-
Level: zap.NewAtomicLevelAt(zap.DebugLevel),
|
| 492 |
-
Development: false,
|
| 493 |
-
DisableStacktrace: os.Getenv(""TEMPORAL_CLI_SHOW_STACKS"") == """",
|
| 494 |
-
Sampling: nil,
|
| 495 |
-
Encoding: ""console"",
|
| 496 |
-
EncoderConfig: encodeConfig,
|
| 497 |
-
OutputPaths: []string{""stderr""},
|
| 498 |
-
ErrorOutputPaths: []string{""stderr""},
|
| 499 |
-
DisableCaller: true,
|
| 500 |
-
}
|
| 501 |
-
logger, _ := config.Build()
|
| 502 |
-
return logger
|
| 503 |
-
}
|
| 504 |
-
|
| 505 |
-
func parseZapLevel(level string) zapcore.Level {
|
| 506 |
-
switch strings.ToLower(level) {
|
| 507 |
-
case ""debug"":
|
| 508 |
-
return zap.DebugLevel
|
| 509 |
-
case ""info"":
|
| 510 |
-
return zap.InfoLevel
|
| 511 |
-
case ""warn"":
|
| 512 |
-
return zap.WarnLevel
|
| 513 |
-
case ""error"":
|
| 514 |
-
return zap.ErrorLevel
|
| 515 |
-
case ""dpanic"":
|
| 516 |
-
return zap.DPanicLevel
|
| 517 |
-
case ""panic"":
|
| 518 |
-
return zap.PanicLevel
|
| 519 |
-
case ""fatal"":
|
| 520 |
-
return zap.FatalLevel
|
| 521 |
-
default:
|
| 522 |
-
return zap.InfoLevel
|
| 523 |
-
}
|
| 524 |
-
}
|
| 525 |
-
",3cbadd97-dd06-4d85-8e23-d8472db56cf4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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