panjf2000 / gnet

🚀 gnet is a high-performance, lightweight, non-blocking, event-driven networking framework written in pure Go.
https://gnet.host
Apache License 2.0
9.69k stars 1.04k forks source link

[Feature]: how to disable logging? replace uber zap with zerolog too pls #555

Closed kolinfluence closed 7 months ago

kolinfluence commented 8 months ago

Description of new feature

uber zap is giving a lot of mem alloc issues

under ddos load, it's generating a lot of garbage coz of gnet usage. the cpu load is higher than my tls.

  1. how to disable logging completely?
  2. pls change to something zero allocation like zerolog or something.

Screenshot from 2024-03-23 00-06-49

Screenshot from 2024-03-23 00-09-05

Scenarios for new feature

improve performance and mem use

Breaking changes or not?

No

Code snippets (optional)

No response

Alternatives for new feature

i want to continue liking gnet

Additional context (optional)

None.

panjf2000 commented 8 months ago

It should only print logs at ERROR and WARN levels by default, what logging outputs were you seeing?

panjf2000 commented 8 months ago

The logging module of gnet is pluggable, which means that you are free to replace the default logger with your own customized logger. If you want to disable the default logger, you can set the environment variable GNET_LOGGING_LEVEL to the highest level FatalLevel (which is "5") before starting your gnet services.

kolinfluence commented 8 months ago

@panjf2000 it was under ddos attack, i'm using github.com/IceFireDB/redhub which uses gnet.

it doesnt show any logs output. do u think it's doing something without showing anything? i put icefiredb under ants.Submit "goroutine". just wondering if it's advisable to use ants on top of gnet services etc.