Coder Social home page Coder Social logo

Group versus Indent? about dax HOT 4 CLOSED

dsherret avatar dsherret commented on July 27, 2024
Group versus Indent?

from dax.

Comments (4)

dsherret avatar dsherret commented on July 27, 2024

I didn't even think about console.group here and I think changing the code to use that instead and rename to logGroup would be beneficial. What I was trying to avoid though is people doing stuff like this:

$.logGroup("Some title");
await $`some_command`;
$.logGroupEnd();

When they really should be writing:

$.logGroup("Some title");
try {
  await $`some_command`;
} finally {
  $.logGroupEnd();
}

So, the provided function (which can be synchronous or asynchronous), forces the try/finally pattern under the hood which is why I prefer it.

Maybe the api should allow people to choose which one they want to do especially where errors being thrown means the process exists, but I kind of like the idea of forcing the try/finally pattern under the hood. I don't have strong feelings though and maybe someone forgetting to do try/finally isn't such a big deal. Thoughts?

from dax.

dsherret avatar dsherret commented on July 27, 2024

Yeah, I think I'll implement both apis after thinking about it, but recommend using the passed in function in API code rather than some top level script.

from dax.

kitsonk avatar kitsonk commented on July 27, 2024

options are great I think... You raise a good point about the potentially needing to do finally, but so far, the way I have handled errors, it wouldn't be a requirement for me... either they get caught and logged, or they terminate the script and the indentation would be outwith that block.

Not to over complicate things, but if you go with the stated version as well, it would be good to be able to determine the current depth.

from dax.

dsherret avatar dsherret commented on July 27, 2024

Working on upgrading some of our scripts today, so implemented this. You can use $.logDepth to get or set the current indent depth.

from dax.

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.