log

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FieldURI                    = "uri"
	FieldURIs                   = "uris"
	FieldURL                    = "url"
	FieldSenderURL              = "sender"
	FieldConfig                 = "config"
	FieldServiceName            = "service"
	FieldServiceIRI             = "serviceIri"
	FieldServiceEndpoint        = "serviceEndpoint"
	FieldActorID                = "actorId"
	FieldOriginActorID          = "originActorId"
	FieldActivityType           = "activityType"
	FieldActivityID             = "activityId"
	FieldMessageID              = "messageId"
	FieldData                   = "data"
	FieldMetadata               = "metadata"
	FieldRequestURL             = "requestUrl"
	FieldRequestHeaders         = "requestHeaders"
	FieldRequestBody            = "requestBody"
	FieldResponse               = "response"
	FieldSize                   = "size"
	FieldMaxSize                = "maxSize"
	FieldCacheExpiration        = "cacheExpiration"
	FieldTarget                 = "target"
	FieldTargets                = "targets"
	FieldTopic                  = "topic"
	FieldHTTPStatus             = "httpStatus"
	FieldHTTPMethod             = "httpMethod"
	FieldParameter              = "parameter"
	FieldParameters             = "parameters"
	FieldAcceptListType         = "acceptListType"
	FieldAdditions              = "additions"
	FieldDeletions              = "deletions"
	FieldReferenceType          = "referenceType"
	FieldAnchorURI              = "anchorUri"
	FieldAnchorURIs             = "anchorURIs"
	FieldAnchorHash             = "anchorHash"
	FieldAnchorEventURI         = "anchorEventUri"
	FieldObjectIRI              = "objectIri"
	FieldReferenceIRI           = "reference"
	FieldKeyID                  = "keyId"
	FieldKeyType                = "keyType"
	FieldKeyOwner               = "keyOwner"
	FieldCurrent                = "current"
	FieldNext                   = "next"
	FieldTotal                  = "total"
	FieldMinimum                = "minimum"
	FieldType                   = "type"
	FieldQuery                  = "query"
	FieldSuffix                 = "suffix"
	FieldSuffixes               = "suffixes"
	FieldVerifiableCredential   = "vc"
	FieldVerifiableCredentialID = "vcId"
	FieldHash                   = "hash"
	FieldHashlink               = "hashlink"
	FieldLocalHashlink          = "localHashlink"
	FieldParent                 = "parent"
	FieldParents                = "parents"
	FieldProof                  = "proof"
	FieldCreatedTime            = "createdTime"
	FieldWitnessURI             = "witnessUri"
	FieldWitnessURIs            = "witnessURIs"
	FieldWitnessPolicy          = "witnessPolicy"
	FieldAnchorOrigin           = "anchorOrigin"
	FieldAnchorOriginEndpoint   = "anchorOriginEndpoint"
	FieldOperationType          = "operationType"
	FieldOperation              = "operation"
	FieldCoreIndex              = "coreIndex"
	FieldKey                    = "key"
	FieldValue                  = "value"
	FieldCID                    = "cid"
	FieldResolvedCID            = "resolvedCid"
	FieldAnchorCID              = "anchorCid"
	FieldCIDVersion             = "cidVersion"
	FieldMultihash              = "multihash"
	FieldCASData                = "casData"
	FieldDomain                 = "domain"
	FieldLink                   = "link"
	FieldLinks                  = "links"
	FieldTaskMgrInstanceID      = "taskMgrInstanceId"
	FieldTaskID                 = "taskId"
	FieldRetries                = "retries"
	FieldMaxRetries             = "maxRetries"
	FieldSubscriberPoolSize     = "subscriberPoolSize"
	FieldTaskMonitorInterval    = "taskMonitorInterval"
	FieldTaskExpiration         = "taskExpiration"
	FieldDeliveryDelay          = "deliveryDelay"
	FieldOperationID            = "operationId"
	FieldPermitHolder           = "permitHolder"
	FieldTimeSinceLastUpdate    = "timeSinceLastUpdate"
	FieldGenesisTime            = "genesisTime"
	FieldSidetreeProtocol       = "sidetreeProtocol"
	FieldSidetreeTxn            = "sidetreeTxn"
	FieldDID                    = "did"
	FieldHRef                   = "href"
	FieldID                     = "id"
	FieldResource               = "resource"
	FieldResolutionResult       = "resolutionResult"
	FieldResolutionModel        = "resolutionModel"
	FieldResolutionEndpoints    = "resolutionEndpoints"
	FieldAuthToken              = "authToken"
	FieldAuthTokens             = "authTokens"
	FieldAddress                = "address"
	FieldAttributedTo           = "attributedTo"
	FieldAnchorLink             = "anchorLink"
	FieldAnchorLinkset          = "anchorLinkset"
	FieldVersion                = "version"
	FieldDeliveryAttempts       = "deliveryAttempts"
	FieldProperty               = "property"
	FieldStorageName            = "storeName"
	FieldIssuer                 = "issuer"
	FieldStatus                 = "status"
	FieldLogURL                 = "logURL"
	FieldNamespace              = "namespace"
	FieldCanonicalRef           = "canonicalRef"
	FieldAnchorString           = "anchorString"
	FieldJRD                    = "jrd"
	FieldBackoff                = "backoff"
	FieldTimeout                = "timeout"
	FieldMaxTime                = "maxTime"
	FieldLogMonitor             = "logMonitor"
	FieldLogMonitors            = "logMonitors"
	FieldIndex                  = "index"
	FieldFromIndex              = "fromIndex"
	FieldToIndex                = "toIndex"
	FieldSource                 = "source"
	FieldAge                    = "age"
	FieldMinAge                 = "minAge"
	FieldDuration               = "duration"
)

Log Fields.

Log levels.

Variables

View Source
var DefaultEncoding = Console

DefaultEncoding sets the default logger encoding. It may be overridden at build time using the -ldflags option.

Functions

func CloseIteratorError

func CloseIteratorError(log *Log, err error)

CloseIteratorError outputs a 'close iterator' error log to the given logger.

func CloseResponseBodyError

func CloseResponseBodyError(log *Log, err error)

CloseResponseBodyError outputs a 'close response body' error log to the given logger.

func GetSpec

func GetSpec() string

GetSpec returns the log spec which specifies the log level of each individual module. The spec is in the following format:

module1=level1:module2=level2:module3=level3:defaultLevel

Example:

module1=error:module2=debug:module3=warning:info

func InvalidParameterValue

func InvalidParameterValue(log *Log, param string, err error)

InvalidParameterValue outputs an 'invalid parameter' log to the given logger.

func ReadRequestBodyError

func ReadRequestBodyError(log *Log, err error)

ReadRequestBodyError outputs a 'read response body' error log to the given logger.

func SetDefaultLevel

func SetDefaultLevel(level Level)

SetDefaultLevel sets the default log level.

func SetLevel

func SetLevel(module string, level Level)

SetLevel sets the log level for given module and level.

func SetSpec

func SetSpec(spec string) error

SetSpec sets the log levels for individual modules as well as the default log level. The format of the spec is as follows:

module1=level1:module2=level2:module3=level3:defaultLevel

Valid log levels are: critical, error, warning, info, debug

Example:

module1=error:module2=debug:module3=warning:info

func WithAcceptListType

func WithAcceptListType(value string) zap.Field

WithAcceptListType sets the accept-list-type field.

func WithActivityID

func WithActivityID(value fmt.Stringer) zap.Field

WithActivityID sets the activity-id field.

func WithActivityType

func WithActivityType(value string) zap.Field

WithActivityType sets the activity-type field.

func WithActorID

func WithActorID(value string) zap.Field

WithActorID sets the actor-id field.

func WithActorIRI

func WithActorIRI(value fmt.Stringer) zap.Field

WithActorIRI sets the actor-id field.

func WithAddress

func WithAddress(value string) zap.Field

WithAddress sets the address field.

func WithAge

func WithAge(value time.Duration) zap.Field

WithAge sets the age field.

func WithAnchorCID

func WithAnchorCID(value string) zap.Field

WithAnchorCID sets the anchor-cid field.

func WithAnchorEventURI

func WithAnchorEventURI(value fmt.Stringer) zap.Field

WithAnchorEventURI sets the anchor-event-uri field.

func WithAnchorEventURIString

func WithAnchorEventURIString(value string) zap.Field

WithAnchorEventURIString sets the anchor-event-uri field.

func WithAnchorHash

func WithAnchorHash(value string) zap.Field

WithAnchorHash sets the anchor-hash field.

func WithAnchorLink(value []byte) zap.Field

WithAnchorLink sets the anchor-link field.

func WithAnchorLinkset

func WithAnchorLinkset(value []byte) zap.Field

WithAnchorLinkset sets the anchor-linkset field.

func WithAnchorOrigin

func WithAnchorOrigin(value interface{}) zap.Field

WithAnchorOrigin sets the anchor-origin field.

func WithAnchorOriginEndpoint

func WithAnchorOriginEndpoint(value interface{}) zap.Field

WithAnchorOriginEndpoint sets the anchor-origin-endpoint field.

func WithAnchorString

func WithAnchorString(value string) zap.Field

WithAnchorString sets the anchor-string field.

func WithAnchorURI

func WithAnchorURI(value fmt.Stringer) zap.Field

WithAnchorURI sets the anchor-uri field.

func WithAnchorURIString

func WithAnchorURIString(value string) zap.Field

WithAnchorURIString sets the anchor-uri field.

func WithAnchorURIStrings

func WithAnchorURIStrings(value ...string) zap.Field

WithAnchorURIStrings sets the anchor-uris field.

func WithAttributedTo

func WithAttributedTo(value string) zap.Field

WithAttributedTo sets the attributed-to field.

func WithAuthToken

func WithAuthToken(value string) zap.Field

WithAuthToken sets the auth-token field.

func WithAuthTokens

func WithAuthTokens(value ...string) zap.Field

WithAuthTokens sets the auth-tokens field.

func WithBackoff

func WithBackoff(value time.Duration) zap.Field

WithBackoff sets the backoff field.

func WithCASData

func WithCASData(value []byte) zap.Field

WithCASData sets the cas-data field.

func WithCID

func WithCID(value string) zap.Field

WithCID sets the cid field.

func WithCIDVersion

func WithCIDVersion(value int) zap.Field

WithCIDVersion sets the cid-version field.

func WithCacheExpiration

func WithCacheExpiration(value time.Duration) zap.Field

WithCacheExpiration sets the cache-expiration field.

func WithCanonicalRef

func WithCanonicalRef(value string) zap.Field

WithCanonicalRef sets the canonical-ref field.

func WithConfig

func WithConfig(value interface{}) zap.Field

WithConfig sets the config field. The value of the field is encoded as JSON.

func WithCoreIndex

func WithCoreIndex(value string) zap.Field

WithCoreIndex sets the coreIndex field.

func WithCreatedTime

func WithCreatedTime(value time.Time) zap.Field

WithCreatedTime sets the created-time field.

func WithCurrentIRI

func WithCurrentIRI(value fmt.Stringer) zap.Field

WithCurrentIRI sets the current field.

func WithDID

func WithDID(value string) zap.Field

WithDID sets the did field.

func WithData

func WithData(value []byte) zap.Field

WithData sets the data field.

func WithDeliveryAttempts

func WithDeliveryAttempts(value int) zap.Field

WithDeliveryAttempts sets the delivery-attempts field.

func WithDeliveryDelay

func WithDeliveryDelay(value time.Duration) zap.Field

WithDeliveryDelay sets the delivery-delay field.

func WithDomain

func WithDomain(value string) zap.Field

WithDomain sets the domain field.

func WithDuration

func WithDuration(value time.Duration) zap.Field

WithDuration sets the duration field.

func WithError

func WithError(err error) zap.Field

WithError sets the error field.

func WithFromIndexUint64

func WithFromIndexUint64(value uint64) zap.Field

WithFromIndexUint64 sets the from-index field.

func WithGenesisTime

func WithGenesisTime(value uint64) zap.Field

WithGenesisTime sets the genesis-time field.

func WithHRef

func WithHRef(value string) zap.Field

WithHRef sets the href field.

func WithHTTPMethod

func WithHTTPMethod(value string) zap.Field

WithHTTPMethod sets the http-method field.

func WithHTTPStatus

func WithHTTPStatus(value int) zap.Field

WithHTTPStatus sets the http-status field.

func WithHash

func WithHash(value string) zap.Field

WithHash sets the hash field.

func WithHashlink(value string) zap.Field

WithHashlink sets the hashlink field.

func WithHashlinkURI

func WithHashlinkURI(value fmt.Stringer) zap.Field

WithHashlinkURI sets the hashlink field.

func WithID

func WithID(value string) zap.Field

WithID sets the id field.

func WithIndex

func WithIndex(value int) zap.Field

WithIndex sets the index field.

func WithIndexUint64

func WithIndexUint64(value uint64) zap.Field

WithIndexUint64 sets the index field.

func WithIssuer

func WithIssuer(value string) zap.Field

WithIssuer sets the issuer field.

func WithJRD

func WithJRD(value interface{}) zap.Field

WithJRD sets the jrd field.

func WithKey

func WithKey(value string) zap.Field

WithKey sets the key field.

func WithKeyID

func WithKeyID(value string) zap.Field

WithKeyID sets the key-id field.

func WithKeyIRI

func WithKeyIRI(value fmt.Stringer) zap.Field

WithKeyIRI sets the key-id field.

func WithKeyOwnerIRI

func WithKeyOwnerIRI(value fmt.Stringer) zap.Field

WithKeyOwnerIRI sets the key-owner field.

func WithKeyType

func WithKeyType(value string) zap.Field

WithKeyType sets the key-type field.

func WithLink(value string) zap.Field

WithLink sets the link field.

func WithLinks(value ...string) zap.Field

WithLinks sets the links field.

func WithLocalHashlink(value string) zap.Field

WithLocalHashlink sets the local-hashlink field.

func WithLogMonitor

func WithLogMonitor(value interface{}) zap.Field

WithLogMonitor sets the log-monitor field.

func WithLogMonitors

func WithLogMonitors(value interface{}) zap.Field

WithLogMonitors sets the log-monitors field.

func WithLogURL

func WithLogURL(value fmt.Stringer) zap.Field

WithLogURL sets the log-url field.

func WithLogURLString

func WithLogURLString(value string) zap.Field

WithLogURLString sets the log-url field.

func WithMaxRetries

func WithMaxRetries(value int) zap.Field

WithMaxRetries sets the max-retries field.

func WithMaxSize

func WithMaxSize(value int) zap.Field

WithMaxSize sets the max-size field.

func WithMaxSizeUInt64

func WithMaxSizeUInt64(value uint64) zap.Field

WithMaxSizeUInt64 sets the max-size field.

func WithMaxTime

func WithMaxTime(value time.Duration) zap.Field

WithMaxTime sets the max-time field.

func WithMessageID

func WithMessageID(value string) zap.Field

WithMessageID sets the message-id field.

func WithMetadata

func WithMetadata(value interface{}) zap.Field

WithMetadata sets the metadata field.

func WithMinAge

func WithMinAge(value time.Duration) zap.Field

WithMinAge sets the min-age field.

func WithMinimum

func WithMinimum(value int) zap.Field

WithMinimum sets the minimum field.

func WithMultihash

func WithMultihash(value string) zap.Field

WithMultihash sets the multihash field.

func WithNamespace

func WithNamespace(value string) zap.Field

WithNamespace sets the namespace field.

func WithNextIRI

func WithNextIRI(value fmt.Stringer) zap.Field

WithNextIRI sets the next field.

func WithObjectIRI

func WithObjectIRI(value fmt.Stringer) zap.Field

WithObjectIRI sets the object-iri field.

func WithOperation

func WithOperation(value interface{}) zap.Field

WithOperation sets the operation field.

func WithOperationID

func WithOperationID(value string) zap.Field

WithOperationID sets the operation-id field.

func WithOperationType

func WithOperationType(value string) zap.Field

WithOperationType sets the operation-type field.

func WithOriginActorID

func WithOriginActorID(value string) zap.Field

WithOriginActorID sets the origin-actor-id field.

func WithParameter

func WithParameter(value string) zap.Field

WithParameter sets the parameter field.

func WithParameters

func WithParameters(value interface{}) zap.Field

WithParameters sets the parameters field.

func WithParent

func WithParent(value string) zap.Field

WithParent sets the parent field.

func WithParentURI

func WithParentURI(value fmt.Stringer) zap.Field

WithParentURI sets the parent field.

func WithParents

func WithParents(value []string) zap.Field

WithParents sets the parents field.

func WithPermitHolder

func WithPermitHolder(value string) zap.Field

WithPermitHolder sets the permit-holder field.

func WithProof

func WithProof(value []byte) zap.Field

WithProof sets the proof field.

func WithProofDocument

func WithProofDocument(value map[string]interface{}) zap.Field

WithProofDocument sets the proof field.

func WithProperty

func WithProperty(value string) zap.Field

WithProperty sets the property field.

func WithQuery

func WithQuery(value interface{}) zap.Field

WithQuery sets the query field. The value of the field is encoded as JSON.

func WithReferenceIRI

func WithReferenceIRI(value fmt.Stringer) zap.Field

WithReferenceIRI sets the reference field.

func WithReferenceType

func WithReferenceType(value string) zap.Field

WithReferenceType sets the reference-type field.

func WithRequestBody

func WithRequestBody(value []byte) zap.Field

WithRequestBody sets the request-body field.

func WithRequestHeaders

func WithRequestHeaders(value http.Header) zap.Field

WithRequestHeaders sets the request-headers field.

func WithRequestURL

func WithRequestURL(value fmt.Stringer) zap.Field

WithRequestURL sets the request-url field.

func WithRequestURLString

func WithRequestURLString(value string) zap.Field

WithRequestURLString sets the request-url field.

func WithResolutionEndpoints

func WithResolutionEndpoints(value ...string) zap.Field

WithResolutionEndpoints sets the resolution-endpoints field.

func WithResolutionModel

func WithResolutionModel(value interface{}) zap.Field

WithResolutionModel sets the resolution-model field.

func WithResolutionResult

func WithResolutionResult(value interface{}) zap.Field

WithResolutionResult sets the resolution-result field.

func WithResolvedCID

func WithResolvedCID(value string) zap.Field

WithResolvedCID sets the resolved-cid field.

func WithResource

func WithResource(value string) zap.Field

WithResource sets the resource field.

func WithResponse

func WithResponse(value []byte) zap.Field

WithResponse sets the response field.

func WithRetries

func WithRetries(value int) zap.Field

WithRetries sets the retries field.

func WithSenderURL

func WithSenderURL(value fmt.Stringer) zap.Field

WithSenderURL sets the sender field.

func WithServiceEndpoint

func WithServiceEndpoint(value string) zap.Field

WithServiceEndpoint sets the service-endpoint field.

func WithServiceIRI

func WithServiceIRI(value fmt.Stringer) zap.Field

WithServiceIRI sets the service-iri field.

func WithServiceName

func WithServiceName(value string) zap.Field

WithServiceName sets the service field.

func WithSidetreeProtocol

func WithSidetreeProtocol(value interface{}) zap.Field

WithSidetreeProtocol sets the sidetree-protocol field.

func WithSidetreeTxn

func WithSidetreeTxn(value interface{}) zap.Field

WithSidetreeTxn sets the sidetree-txn field.

func WithSize

func WithSize(value int) zap.Field

WithSize sets the size field.

func WithSizeUint64

func WithSizeUint64(value uint64) zap.Field

WithSizeUint64 sets the size field.

func WithSource

func WithSource(value string) zap.Field

WithSource sets the source field.

func WithStatus

func WithStatus(value string) zap.Field

WithStatus sets the status field.

func WithStoreName

func WithStoreName(value string) zap.Field

WithStoreName sets the store-name field.

func WithSubscriberPoolSize

func WithSubscriberPoolSize(value int) zap.Field

WithSubscriberPoolSize sets the subscriber-pool-size field.

func WithSuffix

func WithSuffix(value string) zap.Field

WithSuffix sets the suffix field.

func WithSuffixes

func WithSuffixes(value ...string) zap.Field

WithSuffixes sets the suffixes field.

func WithTarget

func WithTarget(value string) zap.Field

WithTarget sets the target field.

func WithTargetIRI

func WithTargetIRI(value fmt.Stringer) zap.Field

WithTargetIRI sets the target field.

func WithTargetIRIs

func WithTargetIRIs(value ...*url.URL) zap.Field

WithTargetIRIs sets the targets field.

func WithTaskExpiration

func WithTaskExpiration(value time.Duration) zap.Field

WithTaskExpiration sets the task-expiration field.

func WithTaskID

func WithTaskID(value string) zap.Field

WithTaskID sets the task-id field.

func WithTaskMgrInstanceID

func WithTaskMgrInstanceID(value string) zap.Field

WithTaskMgrInstanceID sets the task-mgr-instance field.

func WithTaskMonitorInterval

func WithTaskMonitorInterval(value time.Duration) zap.Field

WithTaskMonitorInterval sets the task-monitor-interval field.

func WithTimeSinceLastUpdate

func WithTimeSinceLastUpdate(value time.Duration) zap.Field

WithTimeSinceLastUpdate sets the time-since-last-update field.

func WithTimeout

func WithTimeout(value time.Duration) zap.Field

WithTimeout sets the timeout field.

func WithToIndexUint64

func WithToIndexUint64(value uint64) zap.Field

WithToIndexUint64 sets the to-index field.

func WithTopic

func WithTopic(value string) zap.Field

WithTopic sets the topic field.

func WithTotal

func WithTotal(value int) zap.Field

WithTotal sets the total field.

func WithType

func WithType(value string) zap.Field

WithType sets the type field.

func WithURI

func WithURI(value fmt.Stringer) zap.Field

WithURI sets the uri field.

func WithURIString

func WithURIString(value string) zap.Field

WithURIString sets the uri field.

func WithURIs

func WithURIs(value ...*url.URL) zap.Field

WithURIs sets the uris field.

func WithURL

func WithURL(value fmt.Stringer) zap.Field

WithURL sets the url field.

func WithURLAdditions

func WithURLAdditions(value ...*url.URL) zap.Field

WithURLAdditions sets the additions field.

func WithURLDeletions

func WithURLDeletions(value ...*url.URL) zap.Field

WithURLDeletions sets the deletions field.

func WithURLString

func WithURLString(value string) zap.Field

WithURLString sets the url field.

func WithValue

func WithValue(value interface{}) zap.Field

WithValue sets the value field.

func WithVerifiableCredential

func WithVerifiableCredential(value []byte) zap.Field

WithVerifiableCredential sets the vc field.

func WithVerifiableCredentialID

func WithVerifiableCredentialID(value string) zap.Field

WithVerifiableCredentialID sets the vc-id field.

func WithVersion

func WithVersion(value string) zap.Field

WithVersion sets the version field.

func WithWitnessPolicy

func WithWitnessPolicy(value string) zap.Field

WithWitnessPolicy sets the witness-policy field.

func WithWitnessURI

func WithWitnessURI(value fmt.Stringer) zap.Field

WithWitnessURI sets the witness-uri field.

func WithWitnessURIString

func WithWitnessURIString(value string) zap.Field

WithWitnessURIString sets the witness-uri field.

func WithWitnessURIStrings

func WithWitnessURIStrings(value ...string) zap.Field

WithWitnessURIStrings sets the witness-uris field.

func WithWitnessURIs

func WithWitnessURIs(value ...*url.URL) zap.Field

WithWitnessURIs sets the witness-uris field.

func WriteResponseBodyError

func WriteResponseBodyError(log *Log, err error)

WriteResponseBodyError outputs a 'write response body' error log to the given logger.

func WroteResponse

func WroteResponse(log *Log, data []byte)

WroteResponse outputs a 'wrote response' log to the given logger.

Types

type Encoding

type Encoding = string

Encoding defines the log encoding.

const (
	Console Encoding = "console"
	JSON    Encoding = "json"
)

Log encodings.

type Level

type Level int

Level defines a log level for logging messages.

func GetLevel

func GetLevel(module string) Level

GetLevel returns the log level for the given module.

func ParseLevel

func ParseLevel(level string) (Level, error)

ParseLevel returns the level from the given string.

func (Level) String

func (l Level) String() string

String returns string representation of given log level.

type Log

type Log struct {
	*zap.Logger
	// contains filtered or unexported fields
}

Log uses the Zap Logger to log messages in a structured way.

func New

func New(module string, opts ...Option) *Log

New creates a structured Logger implementation based on given module name.

func (*Log) IsEnabled

func (l *Log) IsEnabled(level Level) bool

IsEnabled returns true if given log level is enabled.

type ObjectMarshaller

type ObjectMarshaller struct {
	// contains filtered or unexported fields
}

ObjectMarshaller uses reflection to marshal an object's fields.

func NewObjectMarshaller

func NewObjectMarshaller(key string, obj interface{}) *ObjectMarshaller

NewObjectMarshaller returns a new ObjectMarshaller.

func (*ObjectMarshaller) MarshalLogObject

func (m *ObjectMarshaller) MarshalLogObject(e zapcore.ObjectEncoder) error

MarshalLogObject marshals the object's fields.

type Option

type Option func(o *options)

Option is a logger option.

func WithEncoding

func WithEncoding(encoding Encoding) Option

WithEncoding sets the output encoding (console or json).

func WithFields

func WithFields(fields ...zap.Field) Option

WithFields sets the fields that will be output with every log.

func WithStdErr

func WithStdErr(stdErr zapcore.WriteSyncer) Option

WithStdErr sets the output for logs of type ERROR, PANIC, and FATAL.

func WithStdOut

func WithStdOut(stdOut zapcore.WriteSyncer) Option

WithStdOut sets the output for logs of type DEBUG, INFO, and WARN.

type StringArrayMarshaller

type StringArrayMarshaller struct {
	// contains filtered or unexported fields
}

StringArrayMarshaller marshals an array of strings into a log field.

func NewStringArrayMarshaller

func NewStringArrayMarshaller(values []string) *StringArrayMarshaller

NewStringArrayMarshaller returns a new StringArrayMarshaller.

func (*StringArrayMarshaller) MarshalLogArray

func (m *StringArrayMarshaller) MarshalLogArray(e zapcore.ArrayEncoder) error

MarshalLogArray marshals the array.

type URLArrayMarshaller

type URLArrayMarshaller struct {
	// contains filtered or unexported fields
}

URLArrayMarshaller marshals an array of URLs into a log field.

func NewURLArrayMarshaller

func NewURLArrayMarshaller(urls []*url.URL) *URLArrayMarshaller

NewURLArrayMarshaller returns a new URLArrayMarshaller.

func (*URLArrayMarshaller) MarshalLogArray

func (m *URLArrayMarshaller) MarshalLogArray(e zapcore.ArrayEncoder) error

MarshalLogArray marshals the array.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL