Coder Social home page Coder Social logo

abstractlogger's People

Contributors

jensneuse avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

davifrag

abstractlogger's Issues

Field struct members should be public

I need to implement a custom logger, so I'm trying to follow the examples shown for zap and logrus. Unfortunately, I'm stuck when getting to the fields function:

abstractlogger/logrus.go

Lines 28 to 49 in 2f170c5

func (l *LogrusLogger) fields(fields []Field) logrus.Fields {
out := make(logrus.Fields, len(fields))
for i := range fields {
switch fields[i].kind {
case StringField:
out[fields[i].key] = fields[i].stringValue
case ByteStringField:
out[fields[i].key] = string(fields[i].byteValue)
case IntField:
out[fields[i].key] = fields[i].intValue
case BoolField:
out[fields[i].key] = fields[i].intValue != 0
case ErrorField, NamedErrorField:
out[fields[i].key] = fields[i].errorValue
case StringsField:
out[fields[i].key] = fields[i].stringsValue
default:
out[fields[i].key] = fields[i].interfaceValue
}
}
return out
}

Because the fields on the Field object such as key, stringValue, etc. are all private:

abstractlogger/field.go

Lines 3 to 12 in 2f170c5

type Field struct {
kind FieldKind
key string
stringValue string
stringsValue []string
intValue int64
byteValue []byte
interfaceValue interface{}
errorValue error
}

They should be public so one can implement their own logger without having to resort to reflection.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.