DEV Community

Cover image for How do YOU debug

How do YOU debug

waylonwalker profile image Waylon Walker ・Updated on ・1 min read

How do YOU debug?

  • debugger?
  • print statements?
  • log files?
  • sending messages to your phone?
  • super simple setup?
  • super complicated setup?

Discussion (19)

Editor guide
jmau111 profile image
Julien Maury


PHP => xdebug, custom logs
js => chrome tools, breakpoints, inspect, I don't use console.logor stuffs like that in file

I try to keep it as simple as possible so easy setup. However, I do think "complicated" setups can be useful sometimes especially if you need some profiling.

waylonwalker profile image
Waylon Walker Author

honestly in js, I always console.log, if I want to go deeper, I right-click store as variable and inspect it from the console. I've wanted to setup a debugger before, but it seems like a lot of setup. Am I wrong in thinking that?

pony profile image

Same here.
I also love to use console.log ))

waylonwalker profile image
Waylon Walker Author

I am with the others so far, print statements cover 95% of my debugging. Most of the time I can trim it down to a very small quick running chunk and a couple of print statements, gives me enough insight.

I would also say that I heavily use the ipython repl which gives me a lot of power to inspect things as I am running things.

I also recently learned about the built in python debugger. I had something buried deep into a pipeline that would only error after running for 10 minutes. Python gives you a very convenient breakpoint() in 3.7+ or import pdb; pdb.set_trace() for python 3.7-. ipython also gives you an incredible magic command to run %debug after an error occurs, to allow you to jump into a debugger right where your last error occurred. Again I am still heavily in the print statement debugging camp.

sargalias profile image
Spyros Argalias

Front end here so we don't tend to keep logs.

95% of the times I debug the scope is fairly small.

  1. I start with a print statement here and there, which is enough most of the time.
  2. If I need to debug properly, I use the debugger with a breakpoint, where I can trace through the code at particular points and see what's happening and what values are.

Other options:

  • If serious debugging is needed I kind of do detective work. I think "what could be wrong?" and go on from there using the debugger on things that could be going wrong.
  • I don't use "binary debugging" but I imagine it would be useful if the scope was quite large.
  • Git bisect (or manually checking out commits) to find the commit where the bug originated. This is very useful because (with a good commit history) it drastically reduces the scope you have to debug.
waylonwalker profile image
Waylon Walker Author

Good one with git bisect. I didn't even think to categorize that as a debugging technique.

Do you fully setup dev tools in your editor to get a debugger running on the front end? I have never done it, so I wonder what the different levels of setup look like. I imagine there is a quick and dirty use browser dev tools up through setting up everything into your editor.

sargalias profile image
Spyros Argalias

Yeah I use git bisect rarely, it can be quite good :).

Ah I haven't really done that in a while because the browser (I do web development) has really good debugging tools. I have used an editor debugger before that "latches on" to the browser debugger, but I haven't used that since my last job because I didn't need to. To use the browser debugger you can write debugger in the JavaScript code where the debugger should start, or just use the browser debugger directly which is fully functional.

Other than that I do use debuggers that don't run in the browser, such as for Node.

ben profile image
Ben Halpern

I'm all about the print statements. Can't quite wrap my head around debug tools when I want to work fast.

When totally lost, deleting code until the problem shows up is my process of elimination technique.... Thank god for modern version control.

waylonwalker profile image
Waylon Walker Author

Thank god for modern version control.

Heck yes. Version control is so valuable for a good debug session. Slice away all you want then figure out what you actually changed once its all said and done.

helderburato profile image
Helder Burato Berto

Commonly in the browser, I debug using chrome inspect and a lot of breakpoints.

Working with React + Redux I use this redux-logger nice middleware to help debug or add my own middleware to Redux, like:

const actionLoggerMiddleware = store => next => action => {
  console.groupCollapsed(action.type);'dispatching', action);
  const result = next(action);
  console.log('next state', store.getState());
  return result;

const middlewares = [networkMiddleware, thunk, actionLoggerMiddleware];
const middlewareEnhancer = applyMiddleware(...middlewares);

Note: networkMiddleware and thunk are the middleware that is enabled in the project I'm working at this moment.

When working with React Native I like to use Reactotron and in some cases, I use this simple package called logger.js for add simple logs with emojis with a more visible way :)

bravemaster619 profile image
bravemaster619 • Edited

Mostly with print statements and log files.

  • Find out which function is causing a problem with log files
  • Copy&paste the function and rename the original function old. e.g. problematic_function_old
  • Add print statements to the copied one.
  • Usually I add print statements one by one. And throw an error immediately after the print statement. In this way, I can do some "unit test" inside a function. Reproduce the error but step by step, figuring out from where it goes wrong.
  • If I'm convinced that the error has been fixed, remove the old function.

OMG, I've been simulating a debugger with print statements. xD
In most cases, I don't use debuggers because they suck!

waylonwalker profile image
Waylon Walker Author

OMG, I've been simulating a debugger with print statements.


I like the idea of copying the function. For some reason I only do this when developing cli tools, but sometimes I will make a verbose flag, then make a separate print function that does an if versbose fro me and i just call vprint for example.

aleksandrhovhannisyan profile image
Aleksandr Hovhannisyan

Print statements all the way.

Debuggers are, to me, very slow and painful when I can often achieve better/faster results just by logging my app's data.

waylonwalker profile image
Waylon Walker Author

I only recently started using a debugger at all. I am still with you for 90% of my use cases though!

storrence88 profile image
Steven Torrence

Pry Rails is a must for me when working with Ruby. Debugger that allows me to stop the code and peek around and test variables. Plus it makes the console format better and with color!

lehmannsystems profile image

Everyone here is a genius so far... print statements all the way :D

hanpari profile image
Pavel Morava

Interactive shell if possible.

I hate myself when I am using print. It is so graceless. πŸ˜‚

richardeschloss profile image
waylonwalker profile image
Waylon Walker Author

Thanks for the Link Richard!