* Fixing possible race condition when passing backoff around as a pointer. * Adding a debug logger that is turned off by default. Info logger is enabled by default but prints out less information. * Removing OK Aurora acknowledgment. * Making Mutex a pointer so that there's no chance it can accidentally be copied. * Changing %v to %+v for composite structs. Removing a repetitive statement for the Aurora return code. * Removing another superflous debug statement. * Removing a leftover helper function from before we changed how we configured the client. * Changing the logging paradigm to only require a single logger. All logging will be disabled by default. If debug is enabled, and a logger has not been set, the library will default to printing all logging (INFO and DEBUG) to the stdout. * Minor changes to demonstrate how a logger can be used in conjunction to debug mode. * Removing port override as it is not needed * Changing code comments to reflect getting rid of port override. * Adding port override back in. * Bug fix: Logger was being set to NOOP despite no logger being provided when debug mode is turned on. * Turn on logging by default. * Removing option to override schema and ports for information found on Zookeeper. * Turning off debug mode for tests because it's too verbose. Making sure LevelLogger is initialized correctly under all scenarios. * Removing override fields for zk config. * Remove space. * Removing info that is now incorrect about zk options.
59 lines
1.3 KiB
Go
59 lines
1.3 KiB
Go
/**
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package realis
|
|
|
|
type Logger interface {
|
|
Println(v ...interface{})
|
|
Printf(format string, v ...interface{})
|
|
Print(v ...interface{})
|
|
}
|
|
|
|
type NoopLogger struct{}
|
|
|
|
func (NoopLogger) Printf(format string, a ...interface{}) {}
|
|
|
|
func (NoopLogger) Print(a ...interface{}) {}
|
|
|
|
func (NoopLogger) Println(a ...interface{}) {}
|
|
|
|
type LevelLogger struct {
|
|
Logger
|
|
debug bool
|
|
}
|
|
|
|
func (l *LevelLogger) EnableDebug(enable bool) {
|
|
l.debug = enable
|
|
}
|
|
|
|
func (l LevelLogger) DebugPrintf(format string, a ...interface{}) {
|
|
if l.debug {
|
|
l.Print("[DEBUG] ")
|
|
l.Printf(format, a)
|
|
}
|
|
}
|
|
|
|
func (l LevelLogger) DebugPrint(a ...interface{}) {
|
|
if l.debug {
|
|
l.Print("[DEBUG] ")
|
|
l.Print(a)
|
|
}
|
|
}
|
|
|
|
func (l LevelLogger) DebugPrintln(a ...interface{}) {
|
|
if l.debug {
|
|
l.Print("[DEBUG] ")
|
|
l.Println(a)
|
|
}
|
|
}
|