Skip to content

Suggestion/Maintenance: change debug logging from level to an enum #4818

Closed

Description

@mqudsi

Since diving deeper into fish's internals, I've found it almost impossible to trace what's going on at a given moment without adding debug(0, L".....") to the code in question and then running with debug logging off. The problem is that there's no real means of determining what log level something should be. If it's what you're working on, it's the most important thing. If it's not, you don't care about it.

This proposal is to switch from numbers to an enum, which can be activated by passing in a bitmask as the parameter to -d instead of a number. This bitmask would specify the component instead of the level, and can even be backwards-compatible with what we have in place by reserving values 0-9:

enum class_t log { //for brevity
    Ignore = 0,
    Error = 1,
    Warn = 2,
    Reserved3 = 3,
    Reserved4 = 4,
    Reserved5 = 5,
    Reserved6 = 6,
    Reserved7 = 7,
    Reserved8 = 8,
    Reserved9 = 9, 
    Completions = 1 << 4,
    JobControl = 1 << 5,
    Tokenizer = 1 << 6,
    Parser = 1 << 7,
    Trace = -1
}

Then you can "opt in" to the log messages you want to receive by specifying -d192' to opt into messages from the tokenizer and parser. Or even fish -d128 -d64to opt in to messages from both these components. Any-d[0-9]` would be interpreted as "this number or lower", while anything 10 or above (well, 16, really) would be interpreted as a bitmask instead.

Activity

  1. zanchey commented on Mar 15, 2018

    @zanchey
    Member

    Having had to calculate the bitmask by hand for various tools (OpenLDAP springs to mind), I am aggressively anti-bitmasks, but as long as you can specify the -d flag more than once it might be reasonable. Having text aliases for them would be a lot more helpful.

  2. added this to the fish-future milestone on Mar 15, 2018
  3. faho commented on Mar 15, 2018

    @faho
    Member

    A better division would certainly be appreciated.

    Like @zanchey, I'm also not sold on bitmasks.

    Ideally, this would work based on "subsystem", of which the filename is an alright approximation, which would make it automatic - no need to add something to the "debug" call to make it go through that system.

  4. ridiculousfish commented on May 28, 2019

    @ridiculousfish
    Member

    This got addressed in b9ef879

  5. locked as resolved and limited conversation to collaborators on Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions