Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1044)

Unified Diff: common/logging/filter.go

Issue 1622553005: Remove log filtering and add stringsetflag. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: error on empty Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « common/logging/fields_test.go ('k') | common/logging/gologger/logger.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/logging/filter.go
diff --git a/common/logging/filter.go b/common/logging/filter.go
deleted file mode 100644
index 41406efd46b31df59166144ea09ebb647f5c1f06..0000000000000000000000000000000000000000
--- a/common/logging/filter.go
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-package logging
-
-import (
- "flag"
- "strings"
-)
-
-const (
- // FilterOnAll is a Filter value that, when included in a Filter, causes it to
- // display all log messages.
- FilterOnAll = "all"
-
- // FilterOnKey is a log field key whose value specifies the context's filter.
- FilterOnKey = "_filterOn"
-)
-
-// Filter is a configurable list of strings to filter on, when the 'filterOn'
-// property is supplied.
-type Filter []string
-
-var _ flag.Value = (*Filter)(nil)
-
-// Set implements flag.Value.
-func (f *Filter) Set(v string) error {
- if len(v) > 0 {
- *f = append(*f, v)
- }
- return nil
-}
-
-// String implements flag.Value.
-func (f *Filter) String() string {
- return strings.Join([]string(*f), ",")
-}
-
-// Get returns a filter function that returns true if the Filter passes the
-// supplied log flags.
-func (f Filter) Get() func(interface{}) bool {
- filterMap := make(map[string]bool)
- for _, filter := range f {
- if filter == FilterOnAll {
- filterMap = nil
- break
- }
- filterMap[filter] = true
- }
-
- return func(filterOn interface{}) bool {
- if filterMap == nil || filterOn == nil {
- return true
- }
-
- switch t := filterOn.(type) {
- case string:
- _, ok := filterMap[t]
- return ok
-
- default:
- return true
- }
- }
-}
« no previous file with comments | « common/logging/fields_test.go ('k') | common/logging/gologger/logger.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698