How to see errors and logs?

Place to get help with not working mods / modding interface.
Post Reply
hoylemd
Inserter
Inserter
Posts: 27
Joined: Tue Apr 17, 2018 2:14 am
Contact:

How to see errors and logs?

Post 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!

User avatar
DaveMcW
Smart Inserter
Smart Inserter
Posts: 3700
Joined: Tue May 13, 2014 11:06 am
Contact:

Re: How to see errors and logs?

Post 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!")

hoylemd
Inserter
Inserter
Posts: 27
Joined: Tue Apr 17, 2018 2:14 am
Contact:

Re: How to see errors and logs?

Post 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?

Bilka
Factorio Staff
Factorio Staff
Posts: 3127
Joined: Sat Aug 13, 2016 9:20 am
Contact:

Re: How to see errors and logs?

Post by Bilka »

hoylemd wrote:As for error messages and stack traces. Where do they appear?
Also in the log file.
I'm an admin over at https://wiki.factorio.com. Feel free to contact me if there's anything wrong (or right) with it.

hoylemd
Inserter
Inserter
Posts: 27
Joined: Tue Apr 17, 2018 2:14 am
Contact:

Re: How to see errors and logs?

Post 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.

hoylemd
Inserter
Inserter
Posts: 27
Joined: Tue Apr 17, 2018 2:14 am
Contact:

Re: How to see errors and logs?

Post 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!

Iccor56
Long Handed Inserter
Long Handed Inserter
Posts: 65
Joined: Mon Dec 25, 2017 12:29 am
Contact:

Re: How to see errors and logs?

Post 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?

User avatar
darkfrei
Smart Inserter
Smart Inserter
Posts: 2903
Joined: Thu Nov 20, 2014 11:11 pm
Contact:

Re: How to see errors and logs?

Post 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

Iccor56
Long Handed Inserter
Long Handed Inserter
Posts: 65
Joined: Mon Dec 25, 2017 12:29 am
Contact:

Re: How to see errors and logs?

Post 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.

User avatar
eradicator
Smart Inserter
Smart Inserter
Posts: 5206
Joined: Tue Jul 12, 2016 9:03 am
Contact:

Re: How to see errors and logs?

Post 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).
Author of: Belt Planner, Hand Crank Generator, Screenshot Maker, /sudo and more.
Mod support languages: 日本語, Deutsch, English
My code in the post above is dedicated to the public domain under CC0.

Post Reply

Return to “Modding help”