multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.38k stars 422 forks source link

Use a logging library for server console #2557

Open ERAGON007 opened 2 years ago

ERAGON007 commented 2 years ago

Is your feature request related to a problem? Please describe.

It's kinda annoying to have server console logs being only black/white. Many developers have a lot of stuff to do in their server console or even observing some console logs in moment.

it can be good to have a nice-looking console logs like using different color messages for Info,Error,Warning,Sucess logs based on their severity. e.g: Info logs can be blue Errors can be in red and etc...

Describe the solution you'd like

I've had some searches on a logging library that can be both Cross-platform and fast, and found these libraries: https://github.com/gabime/spdlog https://github.com/SergiusTheBest/plog

these libraries can also be thread-safe.

CrosRoad95 commented 2 years ago

Along with logging library, lua api for events should be improved, Make possible to change where logs are stored ( not only in server.log file but in for example database ).

Logs should be also improved by using some logs standard, example https://www.loggly.com/ultimate-guide/linux-logging-basics/ - it later can be used for filtering by regex

Disinterpreter commented 2 years ago

( not only in server.log file but in for example database ).

A reason?

There will be good if we have an option to disable writing logs in the files.

CrosRoad95 commented 2 years ago

i meant you should be able to specify where logs are stored, by default server.log

Disinterpreter commented 2 years ago

i meant you should be able to specify where logs are stored, by default server.log

for this case it need to rewrite all mta server for UNIX standards. I don't think somebody approve this.

P.S by modern practice you may write logs only in STDOUT/STDERR.

About the issue IMHO: If you want to color your terminal in Windows - go ahead. you just can do it. But it is useless for real sysadmins and tech-support stuff.

I don't think that colors are necessary. Moreover I think forced ncurses is overengineering and not flexible.

In my practice with similar proprietary software they have:

  1. Ports for wokring (like 22003/22005/ASE)
  2. Controlport (local TCP port or unix socket) You have to connect to control port and press commands.

Real examples: Tor, FreeSWITCH, Asterisk.

so my IMHO is nevermind about which logs have color and which format, Important is I can grab it easy. That's enough.

AlexTMjugador commented 2 years ago

Even though I agree with @Disinterpreter's opinion that colors are not really helpful for knowledgeable people, highlighting warnings and errors with colors might still be valuable to spot relevant messages quickly for those casual server owners that look at the server console window via RDP.

It also is not necessary to bother with ncurses to just print colors nowadays. Virtually any modern terminal emulator, including recent versions of the Windows console host (cmd.exe), can display color ANSI escape codes. On Unix platforms, it's enough to check that the output stream is a TTY and that the TERM environment variable is not set to dumb or unknown to know whether colors should be printed. On older Windows versions (i.e. Windows 7, where only a console host that does not support VT processing is available), it's possible to fall back to Windows Console API calls or just not print colors altogether.

Besides making logs prettier, using a logging framework can make it easier to expand the MTA server logging capabilities to support things like syslog, log rotation and compression, etc.

ERAGON007 commented 2 years ago

( not only in server.log file but in for example database ).

A reason?

Sometimes you just need to split your logs into different files/databases

I don't think that colors are necessary. Moreover I think forced ncurses is overengineering and not flexible.

I think this is needed for debugging purposes/development phase. and colored output CAN help with finding your needed text faster in console (actually this is done client side in debug log well) but not server side.

When you have a ton of server-sided logs. it can be really annoying to stare at console 10 seconds just to find out where you have syntax error....

Although this feature ISN'T necessary BUT can be a nice improvement

Disinterpreter commented 2 years ago

Sometimes you just need to split your logs into different files/databases

No one time-series database are not supporting by MTA. If you want to store, you have to read it from STDOUT/STDERR.

I think this is needed for debugging purposes/development phase. and colored output CAN help with finding your needed text faster in console (actually this is done client side in debug log well) but not server side.

Good idea is send error messages to STDERR. After that you can detect it at your logviewer.

It also is not necessary to bother with ncurses to just print colors nowadays.

I agree with that. But ncurses preinstalled in MTA :)

PlatinMTA commented 2 years ago

Just a reminder that #1011 should also be done imo. No one wants a 1GB file as a log.