log/field.go
func (lf Field) Marshal(visitor Encoder) {
	switch lf.fieldType {
	case stringType:
		visitor.EmitString(lf.key, lf.stringVal)
	case boolType:
		visitor.EmitBool(lf.key, lf.numericVal != 0)
	case intType:
		visitor.EmitInt(lf.key, int(lf.numericVal))
	case int32Type:
		visitor.EmitInt32(lf.key, int32(lf.numericVal))
	case int64Type:
		visitor.EmitInt64(lf.key, int64(lf.numericVal))
	case uint32Type:
		visitor.EmitUint32(lf.key, uint32(lf.numericVal))
	case uint64Type:
		visitor.EmitUint64(lf.key, uint64(lf.numericVal))
	case float32Type:
		visitor.EmitFloat32(lf.key, math.Float32frombits(uint32(lf.numericVal)))
	case float64Type:
		visitor.EmitFloat64(lf.key, math.Float64frombits(uint64(lf.numericVal)))
	case errorType:
		if err, ok := lf.interfaceVal.(error); ok {
			visitor.EmitString(lf.key, err.Error())
		} else {
			visitor.EmitString(lf.key, "<nil>")
		}
	case objectType:
		visitor.EmitObject(lf.key, lf.interfaceVal)
	case lazyLoggerType:
		visitor.EmitLazyLogger(lf.interfaceVal.(LazyLogger))
	case noopType:
		// intentionally left blank
	}
}
func (lf Field) Marshal(visitor Encoder) {
	switch lf.fieldType {
	case stringType:
		visitor.EmitString(lf.key, lf.stringVal)
	case boolType:
		visitor.EmitBool(lf.key, lf.numericVal != 0)
	case intType:
		visitor.EmitInt(lf.key, int(lf.numericVal))
	case int32Type:
		visitor.EmitInt32(lf.key, int32(lf.numericVal))
	case int64Type:
		visitor.EmitInt64(lf.key, int64(lf.numericVal))
	case uint32Type:
		visitor.EmitUint32(lf.key, uint32(lf.numericVal))
	case uint64Type:
		visitor.EmitUint64(lf.key, uint64(lf.numericVal))
	case float32Type:
		visitor.EmitFloat32(lf.key, math.Float32frombits(uint32(lf.numericVal)))
	case float64Type:
		visitor.EmitFloat64(lf.key, math.Float64frombits(uint64(lf.numericVal)))
	case errorType:
		if err, ok := lf.interfaceVal.(error); ok {
			visitor.EmitString(lf.key, err.Error())
		} else {
			visitor.EmitString(lf.key, "<nil>")
		}
	case objectType:
		visitor.EmitObject(lf.key, lf.interfaceVal)
	case lazyLoggerType:
		visitor.EmitLazyLogger(lf.interfaceVal.(LazyLogger))
	case noopType:
		// intentionally left blank
	}
}
func ( lf Field ) Marshal ( visitor Encoder ) { switch lf . fieldType { case stringType : visitor . EmitString ( lf . key , lf . stringVal ) case boolType : visitor . EmitBool ( lf . key , lf . numericVal != 0 ) case intType : visitor . EmitInt ( lf . key , int ( lf . numericVal ) ) case int32Type : visitor . EmitInt32 ( lf . key , int32 ( lf . numericVal ) ) case int64Type : visitor . EmitInt64 ( lf . key , int64 ( lf . numericVal ) ) case uint32Type : visitor . EmitUint32 ( lf . key , uint32 ( lf . numericVal ) ) case uint64Type : visitor . EmitUint64 ( lf . key , uint64 ( lf . numericVal ) ) case float32Type : visitor . EmitFloat32 ( lf . key , math . Float32frombits ( uint32 ( lf . numericVal ) ) ) case float64Type : visitor . EmitFloat64 ( lf . key , math . Float64frombits ( uint64 ( lf . numericVal ) ) ) case errorType : if err , ok := lf . interfaceVal . ( error ) ; ok { visitor . EmitString ( lf . key , err . Error ( ) ) } else { visitor . EmitString ( lf . key , " " ) } case objectType : visitor . EmitObject ( lf . key , lf . interfaceVal ) case lazyLoggerType : visitor . EmitLazyLogger ( lf . interfaceVal . ( LazyLogger ) ) case noopType : // intentionally left blank } }
// Marshal passes a Field instance through to the appropriate
// field-type-specific method of an Encoder.
Marshal passes a Field instance through to the appropriate field - type - specific method of an Encoder .