1 /* 2 Copyright 2020 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package command 18 19 import ( 20 "sync/atomic" 21 ) 22 23 // atomicInt is the global variable for storing the globally set verbosity 24 // level. It should never be used directly to avoid data races. 25 var atomicInt int32 26 27 // SetGlobalVerbose sets the global command verbosity to the specified value 28 func SetGlobalVerbose(to bool) { 29 var i int32 30 if to { 31 i = 1 32 } 33 atomic.StoreInt32(&atomicInt, i) 34 } 35 36 // GetGlobalVerbose returns the globally set command verbosity 37 func GetGlobalVerbose() bool { 38 return atomic.LoadInt32(&atomicInt) != 0 39 } 40