Skip to content

Commit

Permalink
move to "github.com/hyperledger/fabric-lib-go/common/flogging" (#716)
Browse files Browse the repository at this point in the history
* move to "github.com/hyperledger/fabric-lib-go/common/flogging"

Signed-off-by: Angelo De Caro <[email protected]>

* cleanup

Signed-off-by: Angelo De Caro <[email protected]>

* fix unit-test

Signed-off-by: Angelo De Caro <[email protected]>

---------

Signed-off-by: Angelo De Caro <[email protected]>
  • Loading branch information
adecaro authored Dec 17, 2024
1 parent d832523 commit 1083089
Show file tree
Hide file tree
Showing 144 changed files with 378 additions and 4,172 deletions.
4 changes: 2 additions & 2 deletions docs/fabric/fabricdev/core/fabricdev/driver/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/hyperledger-labs/fabric-smart-client/docs/fabric/fabricdev/core/fabricdev"
"github.com/hyperledger-labs/fabric-smart-client/docs/fabric/fabricdev/core/fabricdev/transaction"
"github.com/hyperledger-labs/fabric-smart-client/docs/fabric/fabricdev/core/fabricdev/vault"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/core/generic"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/core/generic/committer"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/core/generic/driver/config"
Expand All @@ -26,14 +27,13 @@ import (
vdriver "github.com/hyperledger-labs/fabric-smart-client/platform/view/driver"
dbdriver "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/db/driver"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/events"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/hash"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/kvs"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/metrics"
"go.opentelemetry.io/otel/trace"
)

var logger = flogging.MustGetLogger("fabric-sdk.core.generic.driver")
var logger = logging.MustGetLogger("fabric-sdk.core.generic.driver")

type Provider struct {
configProvider config.Provider
Expand Down
4 changes: 2 additions & 2 deletions docs/fabric/fabricdev/core/fabricdev/vault/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ SPDX-License-Identifier: Apache-2.0
package vault

import (
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/core/generic/vault"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/core/generic/vault/txidstore"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/driver"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/cache/secondcache"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/db"
dbdriver "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/db/driver"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/metrics"
"github.com/pkg/errors"
"go.opentelemetry.io/otel/trace"
)

var logger = flogging.MustGetLogger("fabric-sdk.core.vault")
var logger = logging.MustGetLogger("fabric-sdk.core.vault")

func New(configService driver.ConfigService, channel string, drivers []dbdriver.NamedDriver, metricsProvider metrics.Provider, tracerProvider trace.TracerProvider) (*Vault, driver.TXIDStore, error) {
var d dbdriver.Driver
Expand Down
4 changes: 2 additions & 2 deletions docs/fabric/fabricdev/core/fabricdev/vault/vault.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"github.com/hyperledger-labs/fabric-smart-client/platform/common/core/generic/vault"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/core/generic/vault/txidstore"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/driver"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
fdriver "github.com/hyperledger-labs/fabric-smart-client/platform/fabric/driver"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/metrics"
"go.opentelemetry.io/otel/trace"
)
Expand All @@ -26,7 +26,7 @@ type (
// NewVault returns a new instance of Vault
func NewVault(store vault.VersionedPersistence, txIDStore TXIDStore, metricsProvider metrics.Provider, tracerProvider trace.TracerProvider) *Vault {
return vault.New[fdriver.ValidationCode](
flogging.MustGetLogger("fabric-sdk.generic.vault"),
logging.MustGetLogger("fabric-sdk.generic.vault"),
store,
txIDStore,
&fdriver.ValidationCodeProvider{},
Expand Down
4 changes: 2 additions & 2 deletions integration/fabric/events/chaincode/views/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import (
"sync"
"time"

"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/services/chaincode"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/assert"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
"github.com/pkg/errors"
)

var logger = flogging.MustGetLogger("view-events")
var logger = logging.MustGetLogger("view-events")

type EventsView struct {
*Events
Expand Down
4 changes: 2 additions & 2 deletions integration/fabric/iou/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (
"github.com/hyperledger-labs/fabric-smart-client/integration"
"github.com/hyperledger-labs/fabric-smart-client/integration/fabric/iou/views"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/common"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
. "github.com/onsi/gomega"
"github.com/prometheus/common/model"
)

var logger = flogging.MustGetLogger("iou-test")
var logger = logging.MustGetLogger("iou-test")

func CreateIOU(ii *integration.Infrastructure, identityLabel string, amount uint, approver string) string {
return CreateIOUWithBorrower(ii, "borrower", identityLabel, amount, approver)
Expand Down
4 changes: 2 additions & 2 deletions integration/fabric/iou/views/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
"time"

"github.com/hyperledger-labs/fabric-smart-client/platform/common/driver"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
)

var logger = flogging.MustGetLogger("fabric.iou")
var logger = logging.MustGetLogger("fabric.iou")

type FinalityListener struct {
ExpectedTxID string
Expand Down
4 changes: 2 additions & 2 deletions integration/integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ import (
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/monitoring"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/orion"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/weaver"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
"github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

var logger = flogging.MustGetLogger("fsc.integration")
var logger = logging.MustGetLogger("fsc.integration")

type Configuration struct {
StartPort int
Expand Down
4 changes: 2 additions & 2 deletions integration/nwo/cmd/network/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (

"github.com/hyperledger-labs/fabric-smart-client/integration"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/api"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
Expand All @@ -24,7 +24,7 @@ type (
)

var (
logger = flogging.MustGetLogger("nwo.network")
logger = logging.MustGetLogger("nwo.network")

path string
topology string
Expand Down
4 changes: 2 additions & 2 deletions integration/nwo/common/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import (
"sync"
"time"

"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
)

var logger = flogging.MustGetLogger("nwo.builder")
var logger = logging.MustGetLogger("nwo.builder")

type BuilderClient struct {
ServerAddress string `json:"server_address"`
Expand Down
4 changes: 2 additions & 2 deletions integration/nwo/common/context/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ package context

import (
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/api"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
view2 "github.com/hyperledger-labs/fabric-smart-client/platform/view/services/client/view"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/grpc"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/view"
)

var logger = flogging.MustGetLogger("fsc.integration")
var logger = logging.MustGetLogger("fsc.integration")

type Builder interface {
Build(path string) string
Expand Down
6 changes: 3 additions & 3 deletions integration/nwo/common/docker/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ import (
"github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
docker "github.com/fsouza/go-dockerclient"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
"github.com/pkg/errors"
)

var logger = flogging.MustGetLogger("fsc.integration.fabric")
var logger = logging.MustGetLogger("fsc.integration.fabric")

// Docker is a helper to manage container related actions within nwo.
type Docker struct {
Expand Down Expand Up @@ -225,7 +225,7 @@ func PortBindings(ports ...int) nat.PortMap {
}

func StartLogs(cli *client.Client, containerID string, loggerName string) error {
dockerLogger := flogging.MustGetLogger(loggerName)
dockerLogger := logging.MustGetLogger(loggerName)
reader, err := cli.ContainerLogs(context.Background(), containerID, container.LogsOptions{
ShowStdout: true,
ShowStderr: true,
Expand Down
4 changes: 2 additions & 2 deletions integration/nwo/common/pkcs11/pkcs11.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import (
"os"
"strings"

"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
"github.com/hyperledger-labs/fabric-smart-client/platform/fabric/core/generic/config"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger/fabric/bccsp"
"github.com/hyperledger/fabric/bccsp/pkcs11"
"github.com/hyperledger/fabric/bccsp/sw"
Expand All @@ -31,7 +31,7 @@ const (
Provider = "PKCS11"
)

var logger = flogging.MustGetLogger("nwo.common.pkcs11")
var logger = logging.MustGetLogger("nwo.common.pkcs11")

// GeneratePrivateKey creates a private key in the HSM and returns its corresponding public key
func GeneratePrivateKey() (*ecdsa.PublicKey, error) {
Expand Down
4 changes: 2 additions & 2 deletions integration/nwo/common/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import (
"syscall"
"time"

"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
"github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
"github.com/pkg/errors"
)

var logger = flogging.MustGetLogger("nwo.runner")
var logger = logging.MustGetLogger("nwo.runner")

// Config defines a Runner.
type Config struct {
Expand Down
4 changes: 2 additions & 2 deletions integration/nwo/fabric/network/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import (
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric/packager"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric/packager/replacer"
"github.com/hyperledger-labs/fabric-smart-client/integration/nwo/fabric/topology"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gexec"
"github.com/tedsuo/ifrit/grouper"
)

var logger = flogging.MustGetLogger("fsc.integration.fabric")
var logger = logging.MustGetLogger("fsc.integration.fabric")

type ChaincodeProcessor interface {
Process(network *Network, cc *topology.ChannelChaincode) *topology.ChannelChaincode
Expand Down
34 changes: 17 additions & 17 deletions integration/nwo/fabric/packager/ccmetadata/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ import (
"regexp"
"strings"

"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger-labs/fabric-smart-client/platform/common/services/logging"
)

var logger = flogging.MustGetLogger("chaincode.platform.metadata")
var logger = logging.MustGetLogger("chaincode.platform.metadata")

// fileValidators are used as handlers to validate specific metadata directories
type fileValidator func(fileName string, fileBytes []byte) error
Expand Down Expand Up @@ -164,13 +164,13 @@ func isJSON(s []byte) (bool, map[string]interface{}) {

func validateIndexJSON(indexDefinition map[string]interface{}) error {

//flag to track if the "index" key is included
// flag to track if the "index" key is included
indexIncluded := false

//iterate through the JSON index definition
// iterate through the JSON index definition
for jsonKey, jsonValue := range indexDefinition {

//create a case for the top level entries
// create a case for the top level entries
switch jsonKey {

case "index":
Expand All @@ -188,7 +188,7 @@ func validateIndexJSON(indexDefinition map[string]interface{}) error {

case "ddoc":

//Verify the design doc is a string
// Verify the design doc is a string
if reflect.TypeOf(jsonValue).Kind() != reflect.String {
return fmt.Errorf("invalid entry, \"ddoc\" must be a string")
}
Expand All @@ -197,7 +197,7 @@ func validateIndexJSON(indexDefinition map[string]interface{}) error {

case "name":

//Verify the name is a string
// Verify the name is a string
if reflect.TypeOf(jsonValue).Kind() != reflect.String {
return fmt.Errorf("invalid entry, \"name\" must be a string")
}
Expand Down Expand Up @@ -232,7 +232,7 @@ func validateIndexJSON(indexDefinition map[string]interface{}) error {
// the next level of the json query
func processIndexMap(jsonFragment map[string]interface{}) error {

//iterate the item in the map
// iterate the item in the map
for jsonKey, jsonValue := range jsonFragment {

switch jsonKey {
Expand All @@ -243,17 +243,17 @@ func processIndexMap(jsonFragment map[string]interface{}) error {

case []interface{}:

//iterate the index field objects
// iterate the index field objects
for _, itemValue := range jsonValueType {

switch reflect.TypeOf(itemValue).Kind() {

case reflect.String:
//String is a valid field descriptor ex: "color", "size"
// String is a valid field descriptor ex: "color", "size"
logger.Debugf("Found index field name: \"%s\"", itemValue)

case reflect.Map:
//Handle the case where a sort is included ex: {"size":"asc"}, {"color":"desc"}
// Handle the case where a sort is included ex: {"size":"asc"}, {"color":"desc"}
err := validateFieldMap(itemValue.(map[string]interface{}))
if err != nil {
return err
Expand All @@ -268,13 +268,13 @@ func processIndexMap(jsonFragment map[string]interface{}) error {

case "partial_filter_selector":

//TODO - add support for partial filter selector, for now return nil
//Take no other action, will be considered valid for now
// TODO - add support for partial filter selector, for now return nil
// Take no other action, will be considered valid for now

default:

//if anything other than "fields" or "partial_filter_selector" was found,
//return an error
// if anything other than "fields" or "partial_filter_selector" was found,
// return an error
return fmt.Errorf("invalid Entry. Entry %s", jsonKey)

}
Expand All @@ -288,13 +288,13 @@ func processIndexMap(jsonFragment map[string]interface{}) error {
// validateFieldMap validates the list of field objects
func validateFieldMap(jsonFragment map[string]interface{}) error {

//iterate the fields to validate the sort criteria
// iterate the fields to validate the sort criteria
for jsonKey, jsonValue := range jsonFragment {

switch jsonValue := jsonValue.(type) {

case string:
//Ensure the sort is either "asc" or "desc"
// Ensure the sort is either "asc" or "desc"
jv := strings.ToLower(jsonValue)
if jv != "asc" && jv != "desc" {
return fmt.Errorf("sort must be either \"asc\" or \"desc\". \"%s\" was found", jsonValue)
Expand Down
6 changes: 3 additions & 3 deletions integration/nwo/fabric/packager/golang/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/pkg/errors"
)

//var logger = flogging.MustGetLogger("nwo.fabric")
// var logger = logging.MustGetLogger("nwo.fabric")

// Platform for chaincodes written in Go
type Platform struct{}
Expand Down Expand Up @@ -145,7 +145,7 @@ func (p *Platform) GetDeploymentPayload(codepath string, replacer replacer.Func)
Name: path.Join("src", pkg.ImportPath, filename),
Path: filepath.Join(pkg.Dir, filename),
}
//logger.Infof("add source [%s][%s]", sd.Name, sd.Path)
// logger.Infof("add source [%s][%s]", sd.Name, sd.Path)
fileMap[sd.Name] = sd
}
}
Expand Down Expand Up @@ -422,7 +422,7 @@ func findSource(cd *CodeDescriptor) (SourceMap, error) {
}

name = filepath.ToSlash(name)
//logger.Infof("add source [%s][%s]", name, path)
// logger.Infof("add source [%s][%s]", name, path)
sources[name] = SourceDescriptor{Name: name, Path: path}
return nil
}
Expand Down
Loading

0 comments on commit 1083089

Please sign in to comment.