MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / TestConsoleIrregularLogPaths

Function TestConsoleIrregularLogPaths

base/logger_console_test.go:296–400  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

294}
295
296func TestConsoleIrregularLogPaths(t *testing.T) {
297 // override min rotation interval for testing
298 originalMinRotationInterval := minLogRotationInterval
299 minLogRotationInterval = time.Millisecond * 10
300 defer func() { minLogRotationInterval = originalMinRotationInterval }()
301
302 testCases := []struct {
303 name string
304 logPath string
305 }{
306 {
307 name: ".log extension",
308 logPath: "foo.log",
309 // take foo-2021-01-01T00-00-00.000.log
310 },
311 {
312 name: "no extension",
313 logPath: "foo",
314 // foo-2021-01-01T00-00-00.000
315 },
316 {
317 name: "multiple dots",
318 logPath: "two.ext.log",
319 // two.ext-2021-01-01T00-00-00.000.log
320 },
321 {
322 name: "start with .",
323 logPath: ".hidden.log",
324 // .hidden-2021-01-01T00-00-00.000.log
325 },
326 {
327 name: "start with ., no ext",
328 logPath: ".hidden",
329 // -2021-01-01T00-00-00.000.hidden
330 },
331 }
332 for _, test := range testCases {
333 t.Run(test.name, func(t *testing.T) {
334 tempdir := lumberjackTempDir(t)
335 config := &ConsoleLoggerConfig{
336 LogLevel: logLevelPtr(LevelDebug),
337 LogKeys: []string{"HTTP"},
338 FileOutput: filepath.Join(tempdir, test.logPath),
339 FileLoggerConfig: FileLoggerConfig{
340 Enabled: Ptr(true),
341 CollationBufferSize: Ptr(0),
342 Rotation: logRotationConfig{
343 RotationInterval: NewConfigDuration(10 * time.Millisecond),
344 },
345 }}
346
347 ctx := TestCtx(t)
348 logger, err := NewConsoleLogger(ctx, false, config)
349 require.NoError(t, err)
350
351 // ensure logging is done before closing the logger
352 wg := sync.WaitGroup{}
353 wg.Add(1)

Callers

nothing calls this directly

Calls 15

logfMethod · 0.95
lumberjackTempDirFunction · 0.85
logLevelPtrFunction · 0.85
PtrFunction · 0.85
NewConfigDurationFunction · 0.85
TestCtxFunction · 0.85
NewConsoleLoggerFunction · 0.85
getDirFilesFunction · 0.85
makeTestFileFunction · 0.85
getDeletionDirAndRegexpFunction · 0.85
DoneMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected