Ren'Py Python (Ren'py): Debug to in-game console?

t727

Well-Known Member
Jan 4, 2018
1,515
1,709
I've managed to log output to the standard out file using print("lol") and configuring different levels(warning, debug, etc) with logging.info("lol").
But I can't find anything on the interwebs how to log output to the in-game console*.

*In-game console being the console you open with shift+o and enable with config.console = True
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,071
14,699
But I can't find anything on the interwebs how to log output to the in-game console*.
Because there isn't. It's obviously possible, but there's no function to do it, you need to create it by yourself.
But why do you want to log on the console ? You already know a way to log on a file, it will give you nothing more. If you want to have real time warning, use , it will be better.
 

t727

Well-Known Member
Jan 4, 2018
1,515
1,709
Because there isn't. It's obviously possible, but there's no function to do it, you need to create it by yourself.
But why do you want to log on the console ? You already know a way to log on a file, it will give you nothing more. If you want to have real time warning, use , it will be better.
I want to log it runtime because the standard out file isn't consistently updating it's content.
The notify is a good suggestion but wouldn't work to cover how I want to be logging things.

You say it's possible, would it be hard to code?
My wild guess being that the in-game console is a system object which can be accessed somehow and written to.
The initial text has to be coded someplace in the core of Python for example.

Being lazy, sorry! I'm now looking through the code of console.rpy trying to see if I can find anything

My assumption can be wrong as I've just done a few changes in existing code. i.e. I haven't done a tutorial or even a working "hello world"
 
Last edited:

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,071
14,699
I want to log it runtime because the standard out file isn't consistently updating it's content.
Then use your own log facility :
Code:
init python:
    import time

    try:    logFile = renpy.os.path.join( config.basedir, 'logFile.txt' )
    except: logFile = None

    def myLog( lvl, msg ):
        if not logFile is None:
            FH = open( logFile, "a" )
            FH.write( "{} {:10} {}\n".format( time.strftime("%d %b %Y %H:%M:%S"), '['+ lvl+']', msg ) )
            FH.close()
        if lvl == "err":
            renpy.notify( "{color=#F00}" + msg )

label whatever:
    $ myLog( "err", "Something gone wrong" )
    $ myLog( "debug", "and it's because of that" )

You say it's possible, would it be hard to code?
I don't know, never really took a look at this part of the code.
 
  • Like
Reactions: t727

drKlauz

Newbie
Jul 5, 2018
40
24
Enable console in renpy launcher and print will write both to game.log and standard windows console.
Code:
label test:
  $print('testing')
This will print to game.log (for later use) and to system console (for real-time use).
 

f95zoneuser463

Member
Game Developer
Aug 14, 2017
219
1,016
But I can't find anything on the interwebs how to log output to the in-game console*.
Not sure if this is known. It's easily overlooked:
For print("text") to show up in the Ren'Py console config.developer must be True.
I guess the check for that is in 00console.rpy line 198 in the Ren'Py 7.2.2 source:
Python:
def stdout_line(l):
    if not config.developer:
        return
    # more ...
 
  • Like
Reactions: Daellhin

t727

Well-Known Member
Jan 4, 2018
1,515
1,709
many words
Thanks for the input
Python:
if config.script_version:
        config.developer = False
        config.default_developer = False
    else:
        config.developer = True
        config.default_developer = True
Is found in 00library.rpy

What I usually do is just
config.console = True
in 00console.rpy

Should I edit 00library.rpy after "if config.script_version:"?

drKlauz
Sorry for not responding earlier. That made the compiler puke some error.