GithubHelp home page GithubHelp logo

Comments (4)

peol avatar peol commented on June 30, 2024

Logging

This is a suggestion how we should implement logging in command line tools.

Note that the commands and their output here might be fictional.

Configuration

We should be using our service logging level conventions as a base, using the same terminology as well as their definitions:
https://core.qlik.com/conventions/logging/#logging-level-definitions

One additional level could be added if we seem fit: SILENT.

The numeric mapping would be:

Level Numeric
TRACE 6
DEBUG 5
INFO 4 (default)
WARN 3
ERROR 2
FATAL 1
SILENT 0
corectl --log-level 6 reload --app foo.qvf
LOG_LEVEL=TRACE corectl --app foo.qvf

The environment variable is useful in e.g. Circle CI to avoid modifying scripts that already runs corectl commands.

Output

The output should, at minimum, be designed for humans. This means plain english and no too cryptic log formats.

In addition, it would be useful to support logging in different formats:

Human readable

corectl reload --app foo.qvf
[06:34:35] WARN: No --app defined, will use an session app instead.
[06:34:35] INFO: Reload started.
[06:34:38] INFO: Reload successful.

JSON

This format could (with benefit) use the logging conventions JSON output, but perhaps defined as an JSON array.

corectl reload --app foo.qvf
[
  {
    "timestamp": "2018-09-27T06:34:35.455Z",
    "logseverity": "WARN",
    "message": "No --app defined, will use an session app instead."
  },
  {
    "timestamp": "2018-09-27T06:34:35.715Z",
    "logseverity": "INFO",
    "message": "Reload started."
  },
  {
    "timestamp": "2018-09-27T06:34:38.119Z",
    "logseverity": "INFO",
    "message": "Reload successful."
  }
]

from corectl.

wennmo avatar wennmo commented on June 30, 2024

I have looked into adding a logging framework in corectl for logging in either plain text and json.

Since we are aiming for being able to customize the output e.g. log keys, format of timestamps and log levels there are atleast two suitable options:

Switching to using either of these framework for logging standard messages (INFO, DEBUG, FATAL etc.) or json traffic from our modules seems doable in a small timeframe. I have a branch where I have started the work on using logrus here.

As I see it there is two bigger tasks that needs to be resolved/discussed before we choose either of these options:

  • How should we handle Table printouts for e.g. an app list in plain text. Should this be printed direcly to stdout, through the logger or be removed? Passing it through the logger seems quite tricky with either of the options above.
  • Currently we are using golden files for integration tests which means that we assert on the printouts from the tool. With a logger adding timestamps this approach can no longer be used, unless we make it the timestamp optional on e.g. a test env variable. We can also change all the test cases to only assert on specific strings in the output, but that will lead to less verification.

from corectl.

wennmo avatar wennmo commented on June 30, 2024

Removing the v1 label on this issue since it is no longer in the scope of the first release.

from corectl.

glooms avatar glooms commented on June 30, 2024

I think we should revisit this issue!

from corectl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.