-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Added ETW logging support for CNS. (#2700)
* Added ETW logging support for CNS. * Renamed unused parameter. Removed punctuation mark from error message. * Added flag to write logs to ETW. Zap logger writes only to ETW in windows. And is NIL in Linux. * Enable ETW logging in CNS through config. * Provide flexibility on zap logging format. * renamed zap logger instance. * Renamed method. * Update cns/logger/cnslogger_windows.go Co-authored-by: Evan Baker <rbtr@users.noreply.github.com> Signed-off-by: sivakami-projects <126191544+sivakami-projects@users.noreply.github.com> * Update cns/logger/cnslogger_linux.go Co-authored-by: Evan Baker <rbtr@users.noreply.github.com> Signed-off-by: sivakami-projects <126191544+sivakami-projects@users.noreply.github.com> * Use Nop core until zap is implemented for all the logs in CNS. Co-authored-by: Evan Baker <rbtr@users.noreply.github.com> Signed-off-by: sivakami-projects <126191544+sivakami-projects@users.noreply.github.com> * return Nopcore for Linux until zap is fully implmemented. Removed flags added to ensure zap instance is not nil. * cganged method name. * Moved zap logger intilization in cnslogger file. Code polishes. --------- Signed-off-by: sivakami-projects <126191544+sivakami-projects@users.noreply.github.com> Co-authored-by: sivakami.sde@gmail.com <t-sivakamis@microsoft.com> Co-authored-by: Evan Baker <rbtr@users.noreply.github.com>
- Loading branch information
1 parent
008dadc
commit 4ae9842
Showing
4 changed files
with
59 additions
and
2 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,9 @@ | ||
package logger | ||
|
||
import ( | ||
"go.uber.org/zap/zapcore" | ||
) | ||
|
||
func getPlatformCores(zapcore.Level, zapcore.Encoder) (zapcore.Core, error) { | ||
return zapcore.NewNopCore(), nil | ||
} |
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,27 @@ | ||
package logger | ||
|
||
import ( | ||
"github.com/Azure/azure-container-networking/zapetw" | ||
"github.com/pkg/errors" | ||
"go.uber.org/zap/zapcore" | ||
) | ||
|
||
const ( | ||
etwCNSEventName = "AzureCNS" | ||
) | ||
|
||
func getPlatformCores(loggingLevel zapcore.Level, encoder zapcore.Encoder) (zapcore.Core, error) { | ||
etwcore, err := getETWCore(loggingLevel, encoder) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "failed to get ETW core") | ||
} | ||
return etwcore, nil | ||
} | ||
|
||
func getETWCore(loggingLevel zapcore.Level, encoder zapcore.Encoder) (zapcore.Core, error) { | ||
etwcore, err := zapetw.NewETWCore(etwCNSEventName, encoder, loggingLevel) | ||
if err != nil { | ||
return nil, errors.Wrap(err, "failed to create ETW core") | ||
} | ||
return etwcore, nil | ||
} |
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