Skip to content

Move wrappers to separate packages #22

@Crocmagnon

Description

@Crocmagnon

Would you be open to moving wrappers to separate packages in this module?

Currently, when importing rockbears/log, log, zap and logrus are built in the binary even if the caller never uses those. Furthermore, since we generally only use one logging lib in our app, there are always two that aren't used. The worst scenario would be for a user to wrap the standard library: they'll get zap and logrus for free.

A modular approach would probably allow for the same functionality while keeping dependency lists clean.
Since the Go toolchain builds entire packages into the final binary, excluding ones that aren't used, splitting the wrappers in separate packages in this module would keep them nearby while not forcing them on users.

It would also allow adding other logging wrappers without bloating end-user binaries.

It would be a breaking change in several ways:

  • wrappers structs, functions and methods would be moved to different packages
  • the global Factory needs to be either defined by the user or we need to find a way to not import logrus while still defining it:

    log/log.go

    Line 22 in fd3fe4c

    var Factory WrapperFactoryFunc = NewLogrusWrapper(logrus.StandardLogger())

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions