-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GetLogSpec to CLI via Admin Service
This CR adds a function to the Admin Service to get the active log spec for a peer and exposes it to Fabric operators via the peer CLI. FAB-12488 #done Change-Id: I9ef379d0653cfe6574dc95850229ff4db02491d9 Signed-off-by: Saad Karim <skarim@us.ibm.com> Signed-off-by: Will Lahti <wtlahti@us.ibm.com> Signed-off-by: Matthew Sykes <sykesmat@us.ibm.com>
- Loading branch information
Showing
9 changed files
with
214 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
Copyright IBM Corp. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package clilogging | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
pb "github.com/hyperledger/fabric/protos/peer" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func getLogSpecCmd(cf *LoggingCmdFactory) *cobra.Command { | ||
var loggingGetLogSpecCmd = &cobra.Command{ | ||
Use: "getlogspec", | ||
Short: "Returns the active log spec.", | ||
Long: `Returns the active logging specification of the peer.`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
return getLogSpec(cf, cmd, args) | ||
}, | ||
} | ||
|
||
return loggingGetLogSpecCmd | ||
} | ||
|
||
func getLogSpec(cf *LoggingCmdFactory, cmd *cobra.Command, args []string) (err error) { | ||
err = checkLoggingCmdParams(cmd, args) | ||
if err == nil { | ||
// Parsing of the command line is done so silence cmd usage | ||
cmd.SilenceUsage = true | ||
|
||
if cf == nil { | ||
cf, err = InitCmdFactory() | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
env := cf.wrapWithEnvelope(&pb.AdminOperation{}) | ||
logResponse, err := cf.AdminClient.GetLogSpec(context.Background(), env) | ||
if err != nil { | ||
return err | ||
} | ||
fmt.Println("Current log spec:") | ||
fmt.Println(logResponse.LogSpec) | ||
} | ||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.