Closed ymaheshwari1 closed 1 year ago
Labels that indicate the severity of a log entry and hence, help in classifying its urgency are termed log levels. They serve on multiple grounds such as separating messages that are just informational from fatal ones, that describe a problem and controlling the application's volume of log output.
Log levels were initially developed in the 1980s by Syslog, a logging solution for the Sendmail project. The severity levels defined by the project later became a standard for logging.
Log levels vary depending on the programming language and framework one is using. Following are the common ones-
FATAL- The FATAL log level represents messages with the greatest severity. It usually means that something critical is broken, and the application cannot continue to do any more useful work without the fix. Examples of situations may be DB failure or running out of disk space on the server.
ERROR- The ERROR log level is used to represent error conditions in an application that prevent a specific operation from running but doesn't mean the application itself will stop working like in FATAL. Examples may include some services not working or some resources not loading.
WARN- The WARN log shows that something unexpected has occurred, yet the application will run as usual. It is mainly used to draw attention to issues that might turn into problems if not checked. Examples can be uncalled resource usage causing the app to slow down.
INFO- The INFO level logs simply state what happened in the application. They are used to indicate useful insights from the business perspective. Examples can be logging a successful job execution or status change.
DEBUG- The DEBUG level is used for logging messages that help developers to diagnose, troubleshoot, or test an application.
TRACE- The TRACE level tracks down the path of code execution. It is mainly used to understand the flow of the program and tackle issues like errors, crashes, etc.
References
Front-end applications have gone very complex with time, the developer has to manage state, API calls, visibility, platforms, browser support, etc thus, generating multiple opportunities for something to go wrong.
References
Tested on numerous popular logging libraries available for Node.js, such as Winston, log4js (log4js-node), and Morgan.
Node-based libraries won't be of any use as polyfills for core node modules like HTTP, path, OS, etc are not available in the browser or in the module bundler (webpack). Hence, won't work on the browser (client) environment.
log4js is available for core JavaScript apps only as it does not have an npm package available for use. One needs to download and set up a min.js file for usage.
loglevel and loglevel-plugin-remote are client-based logging libraries that provide services respectively for logging and posting logs remotely.
POC for the usage- https://github.com/hotwax/ionic-sdk/pull/65/
vue-logger-plugin is a vue-specific library that provides browser logging service and aids in sharing the logs to the server.
POC for the usage- https://github.com/hotwax/ionic-sdk/pull/67
Reference issue on winston js: https://github.com/winstonjs/winston/issues/287
Another library that can be used for logging: https://www.npmjs.com/package/bunyan https://github.com/farpoint/meteor-winston-client
Reference issue on winston js: winstonjs/winston#287
Another library that can be used for logging: https://www.npmjs.com/package/bunyan https://github.com/farpoint/meteor-winston-client
Sir, the meteor-wintston-client requires winston to be set up, hence, the problem again boils down to the inability to use node-based libraries. The same goes for bunyan.
Checkout libraries in below link:
https://www.npmjs.com/search?q=keywords%3ABrowser+logger
We should definitely check: loglevelnext https://www.npmjs.com/package/loglevelnext This project originated as a fork of the much-loved loglevel module, but has diverged and has been rewritten, and now shares similarities only in functional intent.
Adding some more Vue Libraries explored:
vue-pretty-logger License: MIT Last publish: 5 years ago
vuex-action-logger License: ISC Last publish: 6 years ago
vue-debug License: MIT Last publish: 9 years ago
vue-bunyan-logger License: MIT Last publish: 5 years ago
vue-raven License: MIT Last publish: 4 years ago
vuejs-logger License: MIT Last publish: 2 years ago
Thank you, sir. Will explore these.
Sending the logs to the server is a crucial feature. loglevel is quite popular library and could be the first choice but as the loglevel-plugin-remote is not maintained (last release in 2017 ) we chose to go with vue-logger-plugin https://github.com/kutuluk/loglevel-plugin-remote
Initial implementation is done, and applied to Job Manager. Closing this as will have a separate ticket for server side implementation
What is logging?
Logging is the process of recording some detail about application behaviour and storing it in a persistent medium.
Simply put, it is the process of recording relevant data in a store. That data can be information about usage patterns, activities, and operations within an application, or server, etc.
Types
Logs can be of multiple types, each pertaining to a different use case-
Why do we need logging?
Reasons why logging is important-
References-