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

【RFC】Design of OpenIM Log Package Zap #387

Closed
cubxxw opened this issue May 11, 2023 · 9 comments
Closed

【RFC】Design of OpenIM Log Package Zap #387

cubxxw opened this issue May 11, 2023 · 9 comments
Assignees
Labels
feature Categorizes issue or PR as related to a new feature. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. RFC Project design proposal

Comments

@cubxxw
Copy link
Contributor

cubxxw commented May 11, 2023

Design of OpenIM Log Package Zap

Introduction

Add an X-Request-ID field to all logs for a given HTTP request.

  • Fatal handlers: logrus allows one or more handlers to be registered, which are called when a fatal level log occurs. This feature is useful when our program needs to be gracefully shut down.

Disadvantages

  • Low execution efficiency, especially in high-concurrency scenarios
  • Does not support log rotation

Based on the above advantages and disadvantages, I propose the following solution:

  • Use zap as the log package for OpenIM
  • zap is a high-performance, low-latency log package that supports log rotation and multiple output formats
  • zap is similar to logrus, easy to use and learn, and provides multiple log levels

By using zap, OpenIM will obtain better performance and more complete logging functions.

Many excellent open source projects use zap as their log package, such as Kubernetes, etcd, and CockroachDB, as well as the k8s-iam project I am preparing in the future. Therefore, using zap as the log package for OpenIM is also a good choice.

Why choose zap

Zap log package can be well compatible with glog. The encapsulation background is that when developing OpenIM , we found that glog was used extensively in the Kubernetes source code, and the log package needed to be compatible with glog.

Why choose /pkg/log directory

Migrate the log package to the pkg/log directory instead of pkg/common
/log.

  • The first one, the log package belongs to the OpenIM project, and there are customization development contents;
  • The second one, the log package has complete and mature functions, and external projects can also use it.

Basic encapsulated log package support functions

  • Basic functions: support basic log information, support different log levels, support custom configuration, support output to standard output and files.
  • Advanced functions: support multiple log formats, can output by level, support structured logs, support log rotation, and have Hook capability.
  • Optional functions: support color output, compatible with the standard library log package, and support output to different locations.

Test repository

@cubxxw cubxxw added good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. feature Categorizes issue or PR as related to a new feature. RFC Project design proposal labels May 11, 2023
@kubbot
Copy link
Contributor

kubbot commented May 12, 2023

/assign @kubernetes-on

@kubbot
Copy link
Contributor

kubbot commented May 12, 2023

/assign

@kubbot
Copy link
Contributor

kubbot commented May 12, 2023

Details

note

@cubxxw cubxxw self-assigned this May 25, 2023
@cubxxw cubxxw moved this to In progress in openim-powerful May 25, 2023
@kubbot
Copy link
Contributor

kubbot commented Jul 25, 2023

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@cubxxw cubxxw added the help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. label Aug 2, 2023
@kubbot
Copy link
Contributor

kubbot commented Aug 2, 2023

This issue is available for anyone to work on. Make sure to reference this issue in your pull request. ✨ Thank you for your contribution! ✨
Join slack 🤖 to connect and communicate with our developers.
If you wish to accept this assignment, please leave a comment in the comments section: /accept.🎯

@kubbot
Copy link
Contributor

kubbot commented Oct 2, 2023

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

@kubbot
Copy link
Contributor

kubbot commented Oct 19, 2023

This issue was closed because it has been stalled for 7 days with no activity.

@kubbot kubbot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 19, 2023
@github-project-automation github-project-automation bot moved this from In progress to Done in openim-powerful Oct 19, 2023
@cubxxw cubxxw reopened this Oct 19, 2023
@github-project-automation github-project-automation bot moved this from Done to In progress in openim-powerful Oct 19, 2023
@kubbot
Copy link
Contributor

kubbot commented Mar 3, 2024

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

luhaoling added a commit to luhaoling/open-im-server that referenced this issue Mar 5, 2024
* fix: fix the err format

* fix: change the error format

* fix: wrap the errors

* fix: wrap the flagParse error

* fix: fix the InitFromConfig error format
@kubbot
Copy link
Contributor

kubbot commented Mar 11, 2024

This issue was closed because it has been stalled for 7 days with no activity.

@kubbot kubbot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 11, 2024
@github-project-automation github-project-automation bot moved this from In progress to Done in openim-powerful Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Categorizes issue or PR as related to a new feature. good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. RFC Project design proposal
Projects
Status: Done
Development

No branches or pull requests

2 participants