Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Proposal] Add built-in Logger interface #39

Closed
photowey opened this issue Jun 16, 2022 · 1 comment
Closed

[Proposal] Add built-in Logger interface #39

photowey opened this issue Jun 16, 2022 · 1 comment
Assignees

Comments

@photowey
Copy link
Contributor

All log output must be taken over by Logger. If the developer does not provide an implementation, the built-in default log implementation is used.

@photowey photowey changed the title [Proposal] Add built-in Logger interfeace [Proposal] Add built-in Logger interface Jun 16, 2022
@LaurenceLiZhixin
Copy link
Collaborator

LaurenceLiZhixin commented Jun 17, 2022

@photowey Thank you for your proposal. I think it is valuable and needs to be done at present.
For the Logger module, I think the framework needs to be developed from two perspectives.

  1. Built-in Logger. We can provide a logger specially used for logging in the framework-level, that is, compared to current implementations, we should adding log level, log location and other basic information on the basis of retaining 'color'.
    This logger can be defined by user.
    We also need to define a interface like:
// Logger is the interface for Logger types
type Logger interface {
	Info(args ...interface{})
	Warn(args ...interface{})
	Error(args ...interface{})
	Debug(args ...interface{})
	Fatal(args ...interface{})

	Infof(fmt string, args ...interface{})
	Warnf(fmt string, args ...interface{})
	Errorf(fmt string, args ...interface{})
	Debugf(fmt string, args ...interface{})
	Fatalf(fmt string, args ...interface{})
}

I suppose this interface can be placed to extension/normal/logger/logger.go

  1. User Logger under extension/normal/logger/impl/. Developers using the framework can inject logger implementation to this logger interface in their code to print app-level logs. The module needs to provide several preset implementation classes, like extension/normal/logger/impl/console_logger extension/normal/logger/impl/file_logger extension/normal/logger/impl/elastic_logger and so on. Each implementation should have special param and logic, for specific usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants