You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Log support for console apps that use \r to update line (e.g.: progress bars)
Some console apps use \r to move the cursor to the beginning of the current line in order to update progress (e.g.: progress bar). In Dagu, a \r doesn't work, and a new line is printed instead, so the log file is spammed with progress updates.
In order to fix this in Dagu, there would be a need of a buffer to hold the last printed line, so it can be manipulated (with \r) before being written to a file. The web interface should show this last line, even if not written to the log file already (so we can see the progress).
Example script to be used for testing:
#!/usr/bin/env python3importtimeimportsysdefsimulate_progress_bar(total_steps):
bar_size=20# The size of the progress bar in charactersforstepinrange(total_steps+1):
progress=step/total_steps# Calculate the progress as a fractioncompleted_chars=int(bar_size*progress) # Calculate how many characters to fill based on progress# Create the progress bar string: [=====> ]bar='['+'='*completed_chars+' '* (bar_size-completed_chars) +']'# Use \r to overwrite the current line with the updated progress bar and percentagesys.stdout.write('\r'+bar+f' {progress:.1%}')
sys.stdout.flush() # Flush the output to ensure it's immediately visibletime.sleep(0.1) # Simulate a process delay for demonstration purposessys.stdout.write('\n') # Print a newline when the progress is completeif__name__=="__main__":
total_steps=50# Total number of steps for the progresssimulate_progress_bar(total_steps)
The text was updated successfully, but these errors were encountered:
This is more complex than I thought. Some apps won't output progress bars if the terminal is not a "TTY". In some cases progress bars are useful to be logged as they're the only way to keep track of a long running task, but not more than once a second (and in reality a progress bar may be updated many times per second, potentially spamming the log file [like I mentioned in the first post])
Log support for console apps that use \r to update line (e.g.: progress bars)
Some console apps use \r to move the cursor to the beginning of the current line in order to update progress (e.g.: progress bar). In Dagu, a \r doesn't work, and a new line is printed instead, so the log file is spammed with progress updates.
In order to fix this in Dagu, there would be a need of a buffer to hold the last printed line, so it can be manipulated (with \r) before being written to a file. The web interface should show this last line, even if not written to the log file already (so we can see the progress).
Example script to be used for testing:
The text was updated successfully, but these errors were encountered: