hastic-zzz / hastic-server

Hastic data management server for analyzing patterns and anomalies from Grafana
GNU General Public License v3.0
331 stars 23 forks source link

Logging abstraction #894

Open jonyrock opened 4 years ago

jonyrock commented 4 years ago

There is a case when we use (please don't ask why) different kind of logging: https://github.com/hastic/hastic-server/blob/ae5df8745535bbd1e9a98283587f7f2485cf41a2/server/src/services/analytics_service.ts#L64

I propose to have a config and special code everywhere in the codebase where we cna choose logging service: console, file, etc...

jonyrock commented 4 years ago

Alsi this functino https://github.com/hastic/hastic-server/blob/10f46a6e9b7c8008f9a59fe8e5732597240e45bf/server/src/utils/url.ts#L15 as well as everywhere else, I want to do following

console.log('No slashes were provided after the protocol -> inserting slashes');

change to

logging.log(Logging.INFO, 'No slashes were provided after the protocol -> inserting slashes');

... so I add Logging.INFO as first argument to our new Logger service

jonyrock commented 4 years ago

And let's make output as in prometheus:

level=info ts=2020-07-07T13:00:06.231Z caller=head.go:662 component=tsdb msg="Head GC completed" duration=13.73ms
level=warn ts=2020-07-07T13:13:26.643Z caller=main.go:524 msg="Received SIGTERM, exiting gracefully..."