Beispiel #1
0
// NewWithCallDepth creates a new Standard logger for module, and when
// printing file names and line numbers, it goes extraCallDepth up the
// stack from where logger was invoked.
func NewWithCallDepth(module string, extraCallDepth int, iow io.Writer) *Standard {
	log := logging.MustGetLogger(module)
	log.ExtraCalldepth = 1 + extraCallDepth

	// If iow's implementation has an Fd() method, call it and
	// check if the underlying file descriptor is a terminal.
	isTerminal := false
	if fdOwner, ok := iow.(interface {
		Fd() uintptr
	}); ok {
		isTerminal = isatty.IsTerminal(fdOwner.Fd())
	}

	ret := &Standard{
		internal:             log,
		module:               module,
		externalLoggers:      make(map[uint64]ExternalLogger),
		externalLoggersCount: 0,
		externalLogLevel:     keybase1.LogLevel_INFO,
		isTerminal:           isTerminal,
		buffer:               make(chan *entry, 10000),
		drop:                 make(chan bool, 1),
	}
	ret.initLogging(iow)
	go ret.processBuffer()
	return ret
}
Beispiel #2
0
// NewWithCallDepth creates a new Standard logger for module, and when
// printing file names and line numbers, it goes extraCallDepth up the
// stack from where logger was invoked.
func NewWithCallDepth(module string, extraCallDepth int) *Standard {
	log := logging.MustGetLogger(module)
	log.ExtraCalldepth = 1 + extraCallDepth

	ret := &Standard{
		internal: log,
		module:   module,
	}
	ret.setLogLevelInfo()
	return ret
}
Beispiel #3
0
// NewWithCallDepth creates a new Standard logger for module, and when
// printing file names and line numbers, it goes extraCallDepth up the
// stack from where logger was invoked.
func NewWithCallDepth(module string, extraCallDepth int) *Standard {
	log := logging.MustGetLogger(module)
	log.ExtraCalldepth = 1 + extraCallDepth
	ret := &Standard{
		internal:             log,
		module:               module,
		externalLoggers:      make(map[uint64]ExternalLogger),
		externalLoggersCount: 0,
		externalLogLevel:     keybase1.LogLevel_INFO,
	}
	ret.initLogging()
	return ret
}
Beispiel #4
0
// NewWithCallDepth creates a new Standard logger for module, and when
// printing file names and line numbers, it goes extraCallDepth up the
// stack from where logger was invoked.
func NewWithCallDepth(module string, extraCallDepth int, iow io.Writer) *Standard {
	log := logging.MustGetLogger(module)
	log.ExtraCalldepth = 1 + extraCallDepth

	// If iow's implementation has an Fd() method, call it and
	// check if the underlying file descriptor is a terminal.
	isTerminal := false
	if fdOwner, ok := iow.(interface {
		Fd() uintptr
	}); ok {
		isTerminal = isatty.IsTerminal(fdOwner.Fd())
	}

	ret := &Standard{
		internal:   log,
		module:     module,
		isTerminal: isTerminal,
	}
	ret.initLogging(iow)
	return ret
}