hastic-zzz / hastic-server

Hastic data management server for analyzing patterns and anomalies from Grafana

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Logging abstraction

jonyrock opened this issue · comments

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...

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

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..."