-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-2351] Add revert to peer startup log levels
This change adds the mechanism to store the module map at the end at the end of peer startup and adds a method to revert all modules to those levels. It can be called from CLI using 'peer logging revertlevels'. This CR follows https://gerrit.hyperledger.org/r/#/c/7281/. A future CR will update all peer code to use flogging.MustGetLogger instead of logging.MustGetLogger to enable these new features. Change-Id: I297c22b625041e34ebf3a9795ed3b673a63b3212 Signed-off-by: Will Lahti <wtlahti@us.ibm.com>
- Loading branch information
Showing
10 changed files
with
267 additions
and
64 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
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,62 @@ | ||
/* | ||
Copyright IBM Corp. 2017 All Rights Reserved. | ||
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 clilogging | ||
|
||
import ( | ||
"golang.org/x/net/context" | ||
|
||
"github.com/golang/protobuf/ptypes/empty" | ||
"github.com/hyperledger/fabric/peer/common" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
func revertLevelsCmd() *cobra.Command { | ||
return loggingRevertLevelsCmd | ||
} | ||
|
||
var loggingRevertLevelsCmd = &cobra.Command{ | ||
Use: "revertlevels", | ||
Short: "Reverts the logging levels to the levels at the end of peer startup.", | ||
Long: `Reverts the logging levels to the levels at the end of peer startup`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
revertLevels(cmd, args) | ||
}, | ||
} | ||
|
||
func revertLevels(cmd *cobra.Command, args []string) (err error) { | ||
err = checkLoggingCmdParams(cmd, args) | ||
|
||
if err != nil { | ||
logger.Warningf("Error: %s", err) | ||
} else { | ||
adminClient, err := common.GetAdminClient() | ||
if err != nil { | ||
logger.Warningf("%s", err) | ||
return err | ||
} | ||
|
||
_, err = adminClient.RevertLogLevels(context.Background(), &empty.Empty{}) | ||
|
||
if err != nil { | ||
logger.Warningf("%s", err) | ||
return err | ||
} | ||
logger.Info("Log levels reverted to the levels at the end of peer startup.") | ||
} | ||
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
Oops, something went wrong.