• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Discussion Shorter name for show_debug_message - trace()

gnysek

Member
Since we're still in beta, and changing things may happen, I got a proposal to rename show_debug_message() to trace(). First of, this function isn't showing any message and works not only in debug mode - it outputs value to IDE "output" window in both modes. Also, it have no problem with typecasting - you can put string, real or even array and it will print it nicely. So "trace" would not only better describe what it does, but is also much shorter and easier to write in code editor.

This should be a fast change, and on importing projects it can convert all show_debug_messages automatically without compatibility scripts, as it behave exactly same.
 

Mike

nobody important
GMC Elder
This is what I do... first script is "debug()" which is a one line function to show_debug_message().
 

Jobo

Member
GMC Elder
Because it's already there. You don't need two functions doing the same thing, and for people who aren't familiar with GameMaker Language, or scripting in general, show_debug_message is a lot more explicit in what it does. You cannot rename it.
 

gnysek

Member
for people who aren't familiar with GameMaker Language, it doesn't matter even if it's named order_squirrels_to_make_milkshake_and_write_in_output_log() since they just started to learn :) Compared to show_message(), show_debug_message() is more misleading, since it doesn't shows any popup, while first one shows. There's logic behind what I'm asking.
 

Mike

nobody important
GMC Elder
Yes, I'm making exactly same, so why not make it default ? :)
because someone may already use that name for another script, or may prefer Log(), or console_write() or....blah
 

Hyomoto

Member
Here's what I use:
Code:
/// @description log( frequency, values )
/// @param {real} frequency the frequency to perform the logging
/// @param values one or more values to write to the output log
//   any :: function; writes one or more values to the output log
if global.system.developerMode == false { exit }

if argument[ 0 ] == 0 || global.system.tick mod argument[ 0 ] == 0 {
    var _prefix = name + " :: ";
  
    if argument_count == 2 {
        show_debug_message( _prefix + string( argument[ 1 ] ) );
      
    } else {
        var _string = "";
  
        for ( var _i = 1; _i < argument_count; _i++ ) {
            _string += string( argument[ _i ] );
      
        }
        show_debug_message( _prefix + _string );

    }
  
}
I consider show_debug_message fine because I'm not going to type it anyways. I mean, there is a -hell- of a lot of QOL that could be added to show_debug_message, but it would be impossible to tailor it in such a way as to make it broadly useful for any given usage--except in how it currently functions. So in many ways, this is the most ideal implementation because it's not a common term someone might like to use like we have with some built-in variables. There's nothing stopping you from just aliasing it as trace.
 
H

Huder

Guest
And here is what i do:
Code:
/// log(string)
// add a string to log file
var mess = string(current_hour)+":"+string(current_minute)+":"+string(current_second)+"   "+argument0;
file_text_write_string(gLogFile, mess);
file_text_writeln(gLogFile);

show_debug_message(mess);
It outputs debug message to console and also write into file.

gLogFile is a global variable that holds filename for our log file.
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
I think this is a good thing to leave to scripts as logging isn't going to be too taxing and you may want the ability to modify it to also print to file or show on screen or parse custom structures for convenience.
 
A

alexandervrs

Guest
I'd say group all debug related functions under debug_*, so it could be debug_log() :p
 
Top