Documentation ¶
Index ¶
- Constants
- Variables
- func CloseIteratorError(log *Log, err error)
- func CloseResponseBodyError(log *Log, err error)
- func GetSpec() string
- func InvalidParameterValue(log *Log, param string, err error)
- func ReadRequestBodyError(log *Log, err error)
- func SetDefaultLevel(level Level)
- func SetLevel(module string, level Level)
- func SetSpec(spec string) error
- func WithAlias(value string) zap.Field
- func WithAnchorString(value string) zap.Field
- func WithCommitment(value string) zap.Field
- func WithContent(value []byte) zap.Field
- func WithData(value []byte) zap.Field
- func WithDeactivated(value bool) zap.Field
- func WithDocument(value map[string]interface{}) zap.Field
- func WithError(err error) zap.Field
- func WithGenesisTime(value uint64) zap.Field
- func WithHTTPStatus(value int) zap.Field
- func WithID(value string) zap.Field
- func WithIsBatch(value bool) zap.Field
- func WithMaxSize(value int) zap.Field
- func WithNamespace(value string) zap.Field
- func WithOperation(value interface{}) zap.Field
- func WithOperationGenesisTime(value uint64) zap.Field
- func WithOperationID(value string) zap.Field
- func WithOperationType(value string) zap.Field
- func WithOperations(value interface{}) zap.Field
- func WithParameter(value string) zap.Field
- func WithPatch(value interface{}) zap.Field
- func WithRecoveryCommitment(value string) zap.Field
- func WithRequestBody(value []byte) zap.Field
- func WithResolutionModel(value interface{}) zap.Field
- func WithResponse(value []byte) zap.Field
- func WithServiceName(value string) zap.Field
- func WithSidetreeTxn(value interface{}) zap.Field
- func WithSize(value int) zap.Field
- func WithSource(value string) zap.Field
- func WithSources(value ...string) zap.Field
- func WithSuffix(value string) zap.Field
- func WithSuffixes(value ...string) zap.Field
- func WithTotal(value int) zap.Field
- func WithTotalCommitments(value int) zap.Field
- func WithTotalCreateOperations(value int) zap.Field
- func WithTotalDeactivateOperations(value int) zap.Field
- func WithTotalOperations(value int) zap.Field
- func WithTotalPending(value uint) zap.Field
- func WithTotalRecoverOperations(value int) zap.Field
- func WithTotalUpdateOperations(value int) zap.Field
- func WithTransactionNumber(value uint64) zap.Field
- func WithTransactionTime(value uint64) zap.Field
- func WithURIString(value string) zap.Field
- func WithUpdateCommitment(value string) zap.Field
- func WithVersion(value string) zap.Field
- func WithVersionTime(value string) zap.Field
- func WriteResponseBodyError(log *Log, err error)
- func WroteResponse(log *Log, data []byte)
- type Encoding
- type Level
- type Log
- type ObjectMarshaller
- type Option
- type StringArrayMarshaller
Constants ¶
const ( FieldURI = "uri" FieldServiceName = "service" FieldData = "data" FieldRequestBody = "requestBody" FieldResponse = "response" FieldSize = "size" FieldMaxSize = "maxSize" FieldHTTPStatus = "httpStatus" FieldParameter = "parameter" FieldTotal = "total" FieldSuffix = "suffix" FieldSuffixes = "suffixes" FieldOperationType = "operationType" FieldOperation = "operation" FieldOperations = "operations" FieldOperationID = "operationID" FieldGenesisTime = "genesisTime" FieldOperationGenesisTime = "opGenesisTime" FieldSidetreeTxn = "sidetreeTxn" FieldID = "id" FieldResolutionModel = "resolutionModel" FieldVersion = "version" FieldNamespace = "namespace" FieldAnchorString = "anchorString" FieldSource = "source" FieldTotalPending = "totalPending" FieldTransactionTime = "transactionTime" FieldTransactionNumber = "transactionNumber" FieldCommitment = "commitment" FieldRecoveryCommitment = "recoveryCommitment" FieldUpdateCommitment = "updateCommitment" FieldTotalCommitments = "totalCommitments" FieldTotalOperations = "totalOperations" FieldTotalCreateOperations = "totalCreateOperations" FieldTotalUpdateOperations = "totalUpdateOperations" FieldTotalRecoverOperations = "totalRecoverOperations" FieldTotalDeactivateOperations = "totalDeactivateOperations" FieldDocument = "document" FieldDeactivated = "deactivated" FieldVersionTime = "versionTime" FieldPatch = "patch" FieldIsBatch = "isBatch" FieldContent = "content" FieldSources = "sources" FieldAlias = "alias" )
Log Fields.
const ( DEBUG = Level(zapcore.DebugLevel) INFO = Level(zapcore.InfoLevel) WARNING = Level(zapcore.WarnLevel) ERROR = Level(zapcore.ErrorLevel) PANIC = Level(zapcore.PanicLevel) FATAL = Level(zapcore.FatalLevel) )
Log levels.
Variables ¶
var DefaultEncoding = Console
DefaultEncoding sets the default logger encoding. It may be overridden at build time using the -ldflags option.
Functions ¶
func CloseIteratorError ¶
CloseIteratorError outputs a 'close iterator' error log to the given logger.
func CloseResponseBodyError ¶
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 ¶
InvalidParameterValue outputs an 'invalid parameter' log to the given logger.
func ReadRequestBodyError ¶
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 SetSpec ¶
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 WithAnchorString ¶
WithAnchorString sets the anchor-string field.
func WithCommitment ¶
WithCommitment sets the commitment field.
func WithDeactivated ¶
WithDeactivated sets the deactivated field.
func WithDocument ¶
WithDocument sets the document field.
func WithGenesisTime ¶
WithGenesisTime sets the genesis-time field.
func WithHTTPStatus ¶
WithHTTPStatus sets the http-status field.
func WithNamespace ¶
WithNamespace sets the namespace field.
func WithOperation ¶
WithOperation sets the operation field.
func WithOperationGenesisTime ¶
WithOperationGenesisTime sets the op-genesis-time field.
func WithOperationID ¶
WithOperationID sets the operation-id field.
func WithOperationType ¶
WithOperationType sets the operation-type field.
func WithOperations ¶
WithOperations sets the operation field.
func WithParameter ¶
WithParameter sets the parameter field.
func WithRecoveryCommitment ¶
WithRecoveryCommitment sets the recovery-commitment field.
func WithRequestBody ¶
WithRequestBody sets the request-body field.
func WithResolutionModel ¶
WithResolutionModel sets the resolution-model field.
func WithServiceName ¶
WithServiceName sets the service field.
func WithSidetreeTxn ¶
WithSidetreeTxn sets the sidetree-txn field.
func WithSuffixes ¶
WithSuffixes sets the suffixes field.
func WithTotalCommitments ¶
WithTotalCommitments sets the total-commitments field.
func WithTotalCreateOperations ¶
WithTotalCreateOperations sets the total-create-operations field.
func WithTotalDeactivateOperations ¶
WithTotalDeactivateOperations sets the total-deactivate-operations field.
func WithTotalOperations ¶
WithTotalOperations sets the total-operations field.
func WithTotalPending ¶
WithTotalPending sets the total-pending field.
func WithTotalRecoverOperations ¶
WithTotalRecoverOperations sets the total-recover-operations field.
func WithTotalUpdateOperations ¶
WithTotalUpdateOperations sets the total-update-operations field.
func WithTransactionNumber ¶
WithTransactionNumber sets the transaction-number field.
func WithTransactionTime ¶
WithTransactionTime sets the transaction-time field.
func WithUpdateCommitment ¶
WithUpdateCommitment sets the update-commitment field.
func WithVersionTime ¶
WithVersionTime sets the version-time field.
func WriteResponseBodyError ¶
WriteResponseBodyError outputs a 'write response body' error log to the given logger.
func WroteResponse ¶
WroteResponse outputs a 'wrote response' log to the given logger.
Types ¶
type Level ¶
type Level int
Level defines a log level for logging messages.
func ParseLevel ¶
ParseLevel returns the level from the given string.
type Log ¶
Log uses the Zap Logger to log messages in a structured way.
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 ¶
WithEncoding sets the output encoding (console or json).
func WithFields ¶
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.