Is there any list of LÖVE's environment variables?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
molul
Party member
Posts: 264
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

Is there any list of LÖVE's environment variables?

Post by molul »

I'm talking about variables like "XDG_DATA_HOME", "LD_LIBRARY_PATH", "LOVE_GRAPHICS_OPENGLES", etc. I'm precisely looking for a variable that disables all console messages, as I'm getting some "false" errors from SDL that I'd like to remove from the console output.
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: Is there any list of LÖVE's environment variables?

Post by pgimeno »

First, the bad news. I don't think there's such an environment variable. These things are normally handled through redirection of standard output or standard error. In Bourne shells (sh, bash...) that's done with > for standard output and with 2> for standard error. The typical place to send the output when you just want to suppress it is /dev/null.

But for the benefit of others who may search the forums looking for the environment variables supported by LÖVE 11.1:

LÖVE itself reads a few. Some of them are used by PhysFS: XDG_DATA_HOME and HOME (on POSIX systems, e.g. Linux), APPDATA (on Windows, I believe). The love.graphics module uses LOVE_GRAPHICS_DEBUG, not sure what for. Through SDL hints, it also reads LOVE_GRAPHICS_USE_OPENGLES and LOVE_GRAPHICS_USE_GL2. The Lua socket library reads a variable called SERVER_NAME. I didn't find anything else by grepping the sources.

But it's not only LÖVE that reads environment variables. The libraries it uses may also do so. That's the case of LD_LIBRARY_PATH, which is read by the system's dynamic linker library, ld.so; try 'man ld.so' for a complete list, or check here for an online version of the same man page: http://man7.org/linux/man-pages/man8/ld.so.8.html

It's also possible that SDL reads some environment variables, but you'd have to search for these in the SDL docs or sources. A bit of googling has revealed this: https://wiki.libsdl.org/CategoryHints and this: https://wiki.libsdl.org/FAQUsingSDL#Wha ... _by_SDL.3F but neither of them seems very relevant or reliable. There's an old list that applies to SDL 1.2 here: https://www.libsdl.org/release/SDL-1.2. ... vvars.html but it's very likely that these don't apply any longer.

What errors are you getting?
User avatar
zorg
Party member
Posts: 3444
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Is there any list of LÖVE's environment variables?

Post by zorg »

There's one issue regarding the Audio stuff we know about already, and that's on OpenALSoft having a specific order in which it tries backends on linuxes, and it not having a flag to supress such messages, so warnings get tossed to the console... or something.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
molul
Party member
Posts: 264
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

Re: Is there any list of LÖVE's environment variables?

Post by molul »

Thanks a lot for the research, pgimeno! :)

I get this error everytime I press a button (not the D-pad):

Code: Select all

INFO: The key you just pressed is not recognized by SDL. To help get this 
fixed, please report this to the SDL forums/mailing list <https://discourse.libsdl.org/> 
EVDEV KeyCode 304
However, the button is detected and everything works as expected. That's why I wanted to find a way to remove all messages.
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: Is there any list of LÖVE's environment variables?

Post by pgimeno »

Got it. Well, this is a message generated by SDL through its logging subsystem. After a bit of research, I've come up with two possible ways of doing it (for Linux; it might or might not work in OSX and definitely won't work in Windows unless you load the right SDL dynamic library for the OS):

Code: Select all

local ffi = require 'ffi'

local sdl = ffi.load('libSDL2-2.0.so') -- this is the system-dependent line

ffi.cdef [[
  typedef enum
  {
    SDL_LOG_PRIORITY_VERBOSE = 1,
    SDL_LOG_PRIORITY_DEBUG,
    SDL_LOG_PRIORITY_INFO,
    SDL_LOG_PRIORITY_WARN,
    SDL_LOG_PRIORITY_ERROR,
    SDL_LOG_PRIORITY_CRITICAL,
    SDL_NUM_LOG_PRIORITIES
  } SDL_LogPriority;

  enum
  {
    SDL_LOG_CATEGORY_APPLICATION,
    SDL_LOG_CATEGORY_ERROR,
    SDL_LOG_CATEGORY_ASSERT,
    SDL_LOG_CATEGORY_SYSTEM,
    SDL_LOG_CATEGORY_AUDIO,
    SDL_LOG_CATEGORY_VIDEO,
    SDL_LOG_CATEGORY_RENDER,
    SDL_LOG_CATEGORY_INPUT,
    SDL_LOG_CATEGORY_TEST
  };

  void SDL_LogSetPriority(int category, SDL_LogPriority priority);
]]

sdl.SDL_LogSetPriority(sdl.SDL_LOG_CATEGORY_INPUT, sdl.SDL_LOG_PRIORITY_WARN)
The category may be wrong (I can't test because I don't get the same message you get); in that case, try replacing SDL_LOG_CATEGORY_INPUT in the bottom call by one of the other categories until you find the right one. If everything else fails, this seems to work too:

Code: Select all

local ffi = require 'ffi'

local sdl = ffi.load('libSDL2-2.0.so') -- same warning as above

ffi.cdef [[
  typedef enum
  {
    SDL_LOG_PRIORITY_VERBOSE = 1,
    SDL_LOG_PRIORITY_DEBUG,
    SDL_LOG_PRIORITY_INFO,
    SDL_LOG_PRIORITY_WARN,
    SDL_LOG_PRIORITY_ERROR,
    SDL_LOG_PRIORITY_CRITICAL,
    SDL_NUM_LOG_PRIORITIES
  } SDL_LogPriority;

  enum
  {
    SDL_LOG_CATEGORY_APPLICATION,
    SDL_LOG_CATEGORY_ERROR,
    SDL_LOG_CATEGORY_ASSERT,
    SDL_LOG_CATEGORY_SYSTEM,
    SDL_LOG_CATEGORY_AUDIO,
    SDL_LOG_CATEGORY_VIDEO,
    SDL_LOG_CATEGORY_RENDER,
    SDL_LOG_CATEGORY_INPUT,
    SDL_LOG_CATEGORY_TEST
  };


  typedef void (*SDL_LogOutputFunction)(void*           userdata,
                                        int             category,
                                        SDL_LogPriority priority,
                                        const char*     message);
  void SDL_LogSetOutputFunction(SDL_LogOutputFunction callback,
                                void*                 userdata);
  void SDL_LogGetOutputFunction(SDL_LogOutputFunction* callback,
                                void**                 userdata);

]]

local defaultLogFunction = ffi.new('SDL_LogOutputFunction[1]')
local userdata = ffi.new('void*[1]')

local function newLogFunction(userdata, category, priority, message)
  if priority >= sdl.SDL_LOG_PRIORITY_WARN
     or category == sdl.SDL_LOG_CATEGORY_APPLICATION
  then
    defaultLogFunction[0](userdata, category, priority, message)
  end
end

sdl.SDL_LogGetOutputFunction(defaultLogFunction, userdata)
sdl.SDL_LogSetOutputFunction(newLogFunction, userdata)
The idea with 'or category == sdl.SDL_LOG_CATEGORY_APPLICATION' is that if there is any log line generated by LÖVE, it is not filtered out. If you still get the message, which I doubt, commenting out that line should get rid of it.
User avatar
molul
Party member
Posts: 264
Joined: Sun Feb 05, 2012 6:51 pm
Location: Valencia, Spain
Contact:

Re: Is there any list of LÖVE's environment variables?

Post by molul »

Wow! Thanks one more time, pgimeno :) I'll try that hopefully this evening.

EDIT: I struggled a bit with your suggestion, but I finally opted for commenting that line on the SDL source and rebuild all ^^U
Post Reply

Who is online

Users browsing this forum: No registered users and 201 guests