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

Side by Side Diff: client/cmd/logdog_butler/output.go

Issue 1975683002: LogDog: Implement prefix registration in Butler. (Closed) Base URL: https://github.com/luci/luci-go@logdog-butler-register-collector
Patch Set: Rebarse Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « client/cmd/logdog_butler/main.go ('k') | client/cmd/logdog_butler/output_log.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "sort"
9
8 "github.com/luci/luci-go/client/internal/logdog/butler/output" 10 "github.com/luci/luci-go/client/internal/logdog/butler/output"
9 "github.com/luci/luci-go/common/flag/multiflag" 11 "github.com/luci/luci-go/common/flag/multiflag"
10 ) 12 )
11 13
12 type outputFactory interface { 14 type outputFactory interface {
13 option() multiflag.Option 15 option() multiflag.Option
14 configOutput(a *application) (output.Output, error) 16 configOutput(a *application) (output.Output, error)
17 scopes() []string
15 } 18 }
16 19
17 // outputConfigFlag instance that produces a MessageOutput instance when run. 20 // outputConfigFlag instance that produces a MessageOutput instance when run.
18 type outputConfigFlag struct { 21 type outputConfigFlag struct {
19 multiflag.MultiFlag 22 multiflag.MultiFlag
20 } 23 }
21 24
22 // Adds an output factory to this outputConfigFlag instance. 25 // Adds an output factory to this outputConfigFlag instance.
23 func (ocf *outputConfigFlag) AddFactory(f outputFactory) { 26 func (ocf *outputConfigFlag) AddFactory(f outputFactory) {
24 ocf.Options = append(ocf.Options, f.option()) 27 ocf.Options = append(ocf.Options, f.option())
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 // Registers a new output option. This is meant to be called by 'init()' methods 66 // Registers a new output option. This is meant to be called by 'init()' methods
64 // of each option. 67 // of each option.
65 func registerOutputFactory(f outputFactory) { 68 func registerOutputFactory(f outputFactory) {
66 outputFactories = append(outputFactories, f) 69 outputFactories = append(outputFactories, f)
67 } 70 }
68 71
69 // Returns a slice of registered output options. 72 // Returns a slice of registered output options.
70 func getOutputFactories() []outputFactory { 73 func getOutputFactories() []outputFactory {
71 return outputFactories 74 return outputFactories
72 } 75 }
76
77 func allOutputScopes() []string {
78 scopes := make(map[string]struct{})
79 for _, of := range outputFactories {
80 for _, scope := range of.scopes() {
81 scopes[scope] = struct{}{}
82 }
83 }
84
85 allScopes := make([]string, 0, len(scopes))
86 for scope := range scopes {
87 allScopes = append(allScopes, scope)
88 }
89 sort.Strings(allScopes)
90 return allScopes
91 }
OLDNEW
« no previous file with comments | « client/cmd/logdog_butler/main.go ('k') | client/cmd/logdog_butler/output_log.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698