Page 1 of 1

How to see errors and logs?

Posted: Sun Jul 29, 2018 9:50 pm
by hoylemd
Hi folks, I'm new to modding, but not to programming.

I'm working on a macbook, since it's where I have all my programming tools set up. Something is going wrong with the mod I'm working on, and I can't find the error output anywhere. I tried `tail` ing the `factorio-current.log` file, but I didn't see any mod errors there. I also added a line to the mod's `control.lua` script so I will know when I've found the right thing:

Code: Select all

game.players[0].print('Hi Mom!')
But I can't find that output anywhere :(

Some of the stuff I've seen from googling around makes me think that `print()` output and errors should be going to stdout or stderr. Also seems that most modders are testing their mods by running the factorio executable in their command line, so stdout and stderr appear in their terminal. I tried this, but since I have the game installed through Steam, the `factorio` executable (found at `~/Library/Application Support/Steam/steamapps/common/Factorio/factorio.app/MacOS/factorio`) doesn't launch the game such that stdout and stderr are captured - it just launches it and returns to the shell.


So, my questions:
- For those who develop on macos and/or have the game installed through steam, how do you run the game to test your mods?
- Where do mod errors get printed/logged?
- Where does `player.print()` go to?
- What is your favourite colour?

Thanks folks!

Re: How to see errors and logs?

Posted: Sun Jul 29, 2018 10:37 pm
by DaveMcW
game.print() and player.print() display on screen, they are not connected to any external monitoring tool. (Also Lua tables start at 1 so players[0] is an error.)

print() does go to stdout, but stdout is not easy to work with on Steam.

Use this to print to factorio-current.log:

Code: Select all

log("Hi Mom!")

Re: How to see errors and logs?

Posted: Mon Jul 30, 2018 3:29 pm
by hoylemd
Ah darn, that's a shame. Oh well, not the end of the world.

As for error messages and stack traces. Where do they appear?

Re: How to see errors and logs?

Posted: Mon Jul 30, 2018 3:49 pm
by Bilka
hoylemd wrote:As for error messages and stack traces. Where do they appear?
Also in the log file.

Re: How to see errors and logs?

Posted: Mon Jul 30, 2018 5:38 pm
by hoylemd
Hmm, something's weird with my environment then. I was making some tweaks to an existing mod, and I broke some of the functionality (pressing a button just didn't do anything anymore, and I just added a `style` argument to a UI component's `add()` call, so I assumed I made a mistake of some kind), but I didn't see any stack traces or error messages in the log. I might have been doing some other things wrongly though. I'll try it again.

Re: How to see errors and logs?

Posted: Tue Jul 31, 2018 7:55 pm
by hoylemd
Welp, figured that out. Turns out the mod I was working on had a broken 'release' script that would neglect to include the lua source files when bundling up the .zip archive. I have resolved that issue, and am now seeing my log messages appear as expected! hooray!

Re: How to see errors and logs?

Posted: Wed Aug 08, 2018 5:48 pm
by Iccor56
DaveMcW wrote:game.print() and player.print() display on screen, they are not connected to any external monitoring tool. (Also Lua tables start at 1 so players[0] is an error.)

print() does go to stdout, but stdout is not easy to work with on Steam.

Use this to print to factorio-current.log:

Code: Select all

log("Hi Mom!")
player.print() errors. is there a number or name needed somewhere?


Code: Select all

local function Blueprint_Scanner_on_player_mined_entity(event)
	log("on_player_mined_entity start")
	game.print(event.name )
	game.print(event.tick )
end
game.print only prints the event.name every few seconds. but it prints the event.tick every time i mine an entity. any idea why that is?

Re: How to see errors and logs?

Posted: Wed Aug 08, 2018 8:32 pm
by darkfrei
Iccor56 wrote:game.print only prints the event.name every few seconds. but it prints the event.tick every time i mine an entity. any idea why that is?
Antispam

Re: How to see errors and logs?

Posted: Sun Aug 19, 2018 6:00 pm
by Iccor56
darkfrei wrote:
Iccor56 wrote:game.print only prints the event.name every few seconds. but it prints the event.tick every time i mine an entity. any idea why that is?
Antispam

but it is not telling me the things i am telling it to tell me. this is very frustrating. especially when the code is obviously running.

Re: How to see errors and logs?

Posted: Mon Aug 20, 2018 3:15 am
by eradicator
game.print is not meant for continous debugging output. If you want live output use print() or log(). Then start factorio from a terminal/console (win+r 'cmd' return on windows) or use a text editor that can handle real-time updating text files (like notepad2).