本文整理匯總了Golang中github.com/juju/loggo.Logger.Debugf方法的典型用法代碼示例。如果您正苦於以下問題:Golang Logger.Debugf方法的具體用法?Golang Logger.Debugf怎麽用?Golang Logger.Debugf使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/loggo.Logger
的用法示例。
在下文中一共展示了Logger.Debugf方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: prepareOrGetContainerInterfaceInfo
func prepareOrGetContainerInterfaceInfo(
api APICalls,
machineID string,
bridgeDevice string,
allocateOrMaintain bool,
startingNetworkInfo []network.InterfaceInfo,
log loggo.Logger,
) ([]network.InterfaceInfo, error) {
maintain := !allocateOrMaintain
if maintain {
log.Debugf("not running maintenance for machine %q", machineID)
return nil, nil
}
log.Debugf("using multi-bridge networking for container %q", machineID)
containerTag := names.NewMachineTag(machineID)
preparedInfo, err := api.PrepareContainerInterfaceInfo(containerTag)
if err != nil {
return nil, errors.Trace(err)
}
log.Tracef("PrepareContainerInterfaceInfo returned %+v", preparedInfo)
return preparedInfo, nil
}
示例2: logAllSeverities
func logAllSeverities(logger loggo.Logger) {
logger.Criticalf("something critical")
logger.Errorf("an error")
logger.Warningf("a warning message")
logger.Infof("an info message")
logger.Debugf("a debug message")
logger.Tracef("a trace message")
}
示例3: prepareOrGetContainerInterfaceInfo
func prepareOrGetContainerInterfaceInfo(
api APICalls,
machineID string,
bridgeDevice string,
allocateOrMaintain bool,
enableNAT bool,
startingNetworkInfo []network.InterfaceInfo,
log loggo.Logger,
providerType string,
) ([]network.InterfaceInfo, error) {
maintain := !allocateOrMaintain
if environs.AddressAllocationEnabled(providerType) {
if maintain {
log.Debugf("running maintenance for container %q", machineID)
} else {
log.Debugf("trying to allocate static IP for container %q", machineID)
}
allocatedInfo, err := configureContainerNetwork(
machineID,
bridgeDevice,
api,
startingNetworkInfo,
allocateOrMaintain,
enableNAT,
)
if err != nil && !maintain {
log.Infof("not allocating static IP for container %q: %v", machineID, err)
}
return allocatedInfo, err
}
if maintain {
log.Debugf("address allocation disabled: Not running maintenance for machine %q", machineID)
return nil, nil
}
log.Debugf("address allocation feature flag not enabled; using multi-bridge networking for container %q", machineID)
// In case we're running on MAAS 1.8+ with devices support, we'll still
// call PrepareContainerInterfaceInfo(), but we'll ignore a NotSupported
// error if we get it (which means we're not using MAAS 1.8+).
containerTag := names.NewMachineTag(machineID)
preparedInfo, err := api.PrepareContainerInterfaceInfo(containerTag)
if err != nil && errors.IsNotSupported(err) {
log.Warningf("new container %q not registered as device: not running on MAAS 1.8+", machineID)
return nil, nil
} else if err != nil {
return nil, errors.Trace(err)
}
log.Tracef("PrepareContainerInterfaceInfo returned %+v", preparedInfo)
dnsServersFound := false
for _, info := range preparedInfo {
if len(info.DNSServers) > 0 {
dnsServersFound = true
break
}
}
if !dnsServersFound {
logger.Warningf("no DNS settings found, discovering the host settings")
dnsServers, searchDomain, err := localDNSServers()
if err != nil {
return nil, errors.Trace(err)
}
// Since the result is sorted, the first entry is the primary NIC.
preparedInfo[0].DNSServers = dnsServers
preparedInfo[0].DNSSearchDomains = []string{searchDomain}
logger.Debugf(
"setting DNS servers %+v and domains %+v on container interface %q",
preparedInfo[0].DNSServers, preparedInfo[0].DNSSearchDomains, preparedInfo[0].InterfaceName,
)
}
return preparedInfo, nil
}
示例4: prepareOrGetContainerInterfaceInfo
func prepareOrGetContainerInterfaceInfo(
api APICalls,
machineID string,
bridgeDevice string,
allocateOrMaintain bool,
enableNAT bool,
startingNetworkInfo []network.InterfaceInfo,
log loggo.Logger,
) ([]network.InterfaceInfo, error) {
maintain := !allocateOrMaintain
if environs.AddressAllocationEnabled() {
if maintain {
log.Debugf("running maintenance for container %q", machineID)
} else {
log.Debugf("trying to allocate static IP for container %q", machineID)
}
allocatedInfo, err := configureContainerNetwork(
machineID,
bridgeDevice,
api,
startingNetworkInfo,
allocateOrMaintain,
enableNAT,
)
if err != nil && !maintain {
log.Infof("not allocating static IP for container %q: %v", machineID, err)
}
return allocatedInfo, err
}
if maintain {
log.Debugf("address allocation disabled: Not running maintenance for machine %q", machineID)
return nil, nil
}
log.Debugf("address allocation feature flag not enabled; using DHCP for container %q", machineID)
// In case we're running on MAAS 1.8+ with devices support, we'll still
// call PrepareContainerInterfaceInfo(), but we'll ignore a NotSupported
// error if we get it (which means we're not using MAAS 1.8+).
containerTag := names.NewMachineTag(machineID)
preparedInfo, err := api.PrepareContainerInterfaceInfo(containerTag)
if err != nil && errors.IsNotSupported(err) {
log.Warningf("new container %q not registered as device: not running on MAAS 1.8+", machineID)
return nil, nil
} else if err != nil {
return nil, errors.Trace(err)
}
dnsServers, searchDomain, dnsErr := localDNSServers()
if dnsErr != nil {
return nil, errors.Trace(dnsErr)
}
for i, _ := range preparedInfo {
preparedInfo[i].DNSServers = dnsServers
preparedInfo[i].DNSSearch = searchDomain
}
log.Tracef("PrepareContainerInterfaceInfo returned %#v", preparedInfo)
// Most likely there will be only one item in the list, but check
// all of them for forward compatibility.
macAddresses := set.NewStrings()
for _, prepInfo := range preparedInfo {
macAddresses.Add(prepInfo.MACAddress)
}
log.Infof(
"new container %q registered as a MAAS device with MAC address(es) %v",
machineID, macAddresses.SortedValues(),
)
return preparedInfo, nil
}