Log commands without LOGOPEN

More
28 Oct 2023 10:44 - 28 Oct 2023 10:47 #283952 by TooTall18T
I am working on my tool changing routine again and I'm not sure about something right now.

For debugging the subroutine has a debug_mode parameter. The user can set it to "1" and the subroutine writes a log-file.
;-3- Create debug mode log file
o<10> if [#<debug_mode> EQ 1]
  (debug, logfile.txt created in the configuration folder)
  (logopen,logfile.txt)
  (log, Log file for the subroutine "tool_touch_off.ngc" Version 3.1.0 from TooTall18T)
  (log, Fast: #<fast_probe_fr>;)
....

There are additional log commands in some places in the routine. The routine checks if the debug_mode is set to "1". But is that needed?
o<16> if [#<debug_mode> EQ 1]
  (log, Old tool length: #<tool_length_old>;)
o<16>endif

Would it be a problem if I delete the o-codes for the additional log commands and leave only the logopen command in a o-code if statement?
I tested it without visible issues. But I'm not sure if there a any invisible issues.
The only thing I see is when a log file is already open it is written there even if the debug_mode is set to "0". But this could be prevented with a logclose command at the beginning of the routine.
Last edit: 28 Oct 2023 10:47 by TooTall18T.

Please Log in or Create an account to join the conversation.

More
28 Oct 2023 18:04 #283977 by andypugh
Are you asking if it is OK to command a (log...) without a (logopen...)?

To be honest, I don't know.

But:
github.com/LinuxCNC/linuxcnc/blob/2.9/sr...sk/emccanon.cc#L2375

Seems to indicate that it just does nothing if there is no logfile defined.

Please Log in or Create an account to join the conversation.

More
28 Oct 2023 18:26 - 28 Oct 2023 18:34 #283978 by TooTall18T

Are you asking if it is OK to command a (log...) without a (logopen...)?

Yes, that was my question.
I didn't know where to start searching in the source code. And maybe there would be more than I could find.

Seems to indicate that it just does nothing if there is no logfile defined.

That's what it looks like to me too.

Thank you.
Last edit: 28 Oct 2023 18:34 by TooTall18T.

Please Log in or Create an account to join the conversation.

Time to create page: 0.214 seconds
Powered by Kunena Forum