forked from Juniper/go-netconf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enable rpc message logging for debug purposes issue Juniper#68
- Loading branch information
1 parent
69aaf3d
commit fd11cbb
Showing
4 changed files
with
72 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Go NETCONF Client | ||
// | ||
// Copyright (c) 2013-2018, Juniper Networks, Inc. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package netconf | ||
|
||
import ( | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
) | ||
|
||
func init() { | ||
// Discard is an io.Writer on which all Write calls succeed without doing anything. | ||
Logger.SetOutput(ioutil.Discard) | ||
} | ||
|
||
// NopLogger is a wrapper for the standard logger | ||
type NopLogger struct { | ||
*log.Logger | ||
} | ||
|
||
// Logger provides request and response payload logging for the Netconf Exec | ||
var Logger = &NopLogger{ | ||
log.New(os.Stderr, "", log.LstdFlags), | ||
} |
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,34 @@ | ||
// Go NETCONF Client | ||
// | ||
// Copyright (c) 2013-2018, Juniper Networks, Inc. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package netconf | ||
|
||
import ( | ||
"io/ioutil" | ||
"log" | ||
"os" | ||
"testing" | ||
) | ||
|
||
func BenchmarkLog(b *testing.B) { | ||
log.SetFlags(log.LstdFlags) | ||
file, err := ioutil.TempFile("", "benchmark-log") | ||
if err != nil { | ||
log.SetOutput(os.Stderr) | ||
} else { | ||
log.SetOutput(file) | ||
} | ||
b.ResetTimer() | ||
for i := 0; i < b.N; i++ { | ||
log.Printf("Benchmark %d", i) | ||
} | ||
} | ||
|
||
func BenchmarkNopLogger(b *testing.B) { | ||
for i := 0; i < b.N; i++ { | ||
Logger.Println("Benchmark %d", i) | ||
} | ||
} |
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