Categorygithub.com/wego/pkg/logger
modulepackage
0.2.3
Repository: https://github.com/wego/pkg.git
Documentation: pkg.go.dev

# Functions

ContextWithRequest returns a new context from a parent context with request added into it.
ContextWithRequestType returns a new context from a parent context with request type added into it.
Init initializes loggers.
LogPartnerRequest logs a partner request to local file.
LogRequest logs a request to local file.
LogUltronEx logs a msg to UltronEx local file.
MaskJSON mask parts of the json key paths value from the input json with replacement Example: input = ` { "first": "first value", "second": { "first": "1st of second", "second": "[email protected]", "third": { "first": "1st of second third", "second": "2nd of second third", "third": "3rd of second third", } } }` maskData := []logger.MaskData{ { JSONKey: []string{"first"}, FistCharsToShow: 3, LastCharsToShow: 6, KeepSameLength: true, }, { JSONKey: []string{"second", "second"}, FistCharsToShow: 2, LastCharsToShow: 3, CharsToIgnore: []rune{'@'}, KeepSameLength: true, }, { JSONKey: []string{"second", "third", "first"}, FistCharsToShow: 3, LastCharsToShow: 1, KeepSameLength: true, }, } MaskJSON(input, "!", maskData) will return { "first": "fir!! value", "second": { "first": "1st of second", "second": "se!!!!@!!!!!com", "third": { "first": "1st!!!!!!!!!!!!!!!d", "second": "2nd of second third", "third": "3rd of second third", } } }.
MaskXML masks parts of the inner text of tags from the input XML with replacement.
RedactJSON replaces value of key paths from the input JSON with replacement or defaultReplacement when replacement is empty Example: input = ` { "first": "first value", "second": { "first": "1st of second", "second": "2nd of second", "third": { "first": "1st of second third", "second": "2nd of second third", "third": "3rd of second third", } } }` keys := [][]string{{"first"}, {"second", "second"}, {"second", "third", "first"}} RedactJSON(input, "Wego", keys) will return { "first": "Wego", "second": { "first": "1st of second", "second": "Wego", "third": { "first": "Wego", "second": "2nd of second third", "third": "3rd of second third", } } }.
RedactXML replaces inner text of tags from the input XML with replacement or defaultReplacement when replacement is empty.
RequestFromContext gets the request from context.
RequestTypeFromContext gets the request type from context.
Sync syncs all loggers.

# Constants

MaskRestrictionTypeEmail will only mask email text.

# Structs

MaskData the data as well as the information on how to mask the data.
Request contains general information of a request.
UltronExMsg ...

# Type aliases

Headers ...
MaskRestrictionType the type of text to mask, will only mask if text is of the specified type.
RequestType ...