Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7777661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T18:11:59+00:00 2026-06-01T18:11:59+00:00

Rather than go back through my libraries and adding a debug flag parameter, I

  • 0

Rather than go back through my libraries and adding a “debug” flag parameter, I thought that once a debug flag (0/1) was read on the command line of my application, a ref could be set once and then accessed by any function that needed to do something if the debug flag is set.

Is that a reasonable way to handle parameter-less debugging, or is my thinking too much like having a “forbidden” global variable?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T18:12:01+00:00Added an answer on June 1, 2026 at 6:12 pm

    A global for this sort of thing is fine, although using a ref to store it isn’t really appropriate because then you’d need to do all your logging in a transaction (ie. within a (dosync)).

    Since you are unlikely to really care about race conditions on your ‘logging-enabled’ it doesn’t need special protection. You’d mark this variable with ear-muffs to signal it has special meaning….

    Something like this would be fine:

    (def ^{:dynamic true} *debug-enabled* false)
    (def ^{:dynamic true} *info-enabled* false)
    
    (defn- log [level s]
      (println (apply str (cons (str "[" level "] ") s))))
    
    (defn debug [ & s ]
      (when *debug-enabled*
        (log "DEBUG" s)))
    
    (defn info [ & s ]
      (when *info-enabled*
        (log "INFO" s)))
    

    Note that by defining the *debug-enabled* flag dynamic you can switch on debug for just parts of your code. In this example, imagine that all the functions used the (debug) functions mentioned above. You have *debug-enabled* set to false, but you’d like to turn it on just for (my-problematic-func). You can re-bind the flag just for that call like this:

    (myfunc a b c)
    (my-other-func d e f)
    (binding [*debug-enabled* true] ; switch on debug for my-problematic-func
       (my-problematic-func g h i))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

rather than using a textnode to show content im trying to figure out how
Rather than reinvent the wheel I would like to use Outlook to manage my
Rather than just grabbing the user's friends' emails, I want to show their list
Rather than doing my_var = my_var+'extra string'; is there a shorthand method like .=
Rather than have everything in one big dialog, I'm looking at being able to
Rather than have a NULL in a column, I want a 0 to be
Rather than pushing a release to PyPi and GitHub, it would be easier to
Rather than create, and then drop a table in sqlite3, I would like to
SQLite3 uses dynamic typing rather than static typing, in contrast to other flavors of
From a post-compilation perspective (rather than a coding syntax perspective), in C#, is there

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.