It is OK to log WARN messages to log.txt in production modules?

I have some code associated with my theme system which looks like this:

    if(rack::system::exists(asset::plugin(pluginInstance, svg_path)))
    {
      std::shared_ptr<Svg> svg = APP->window->loadSvg(asset::plugin(pluginInstance, svg_path));
      VoxglitchPanel *voxglitch_panel = new VoxglitchPanel;
      voxglitch_panel->setBackground(svg);
      addChild(voxglitch_panel);
    }

For some users, the asset doesn’t exist and I’m trying to find out why. In the long term, am I allowed to log warnings to rack’s log.txt, like so?

    if(rack::system::exists(asset::plugin(pluginInstance, svg_path)))
    {
      std::shared_ptr<Svg> svg = APP->window->loadSvg(asset::plugin(pluginInstance, svg_path));
      VoxglitchPanel *voxglitch_panel = new VoxglitchPanel;
      voxglitch_panel->setBackground(svg);
      addChild(voxglitch_panel);
    }
    else
    {
        std::string message = "Unable to load theme file from" + std::to_string(asset::plugin(pluginInstance, svg_path));
        WARN(message.to_str());  // <======= is this OK to do?
    }

It should be fine. I don’t think there are log file police, LOL. So long as you are not adding a huge number of messages, it should be fine.

1 Like

It is probably a good idea to get an authoritative answer to this. In the early days of Meander, my module got rejected in the library review due to the fact that I inadvertently had some warnings going to the log file. It was not a gigantic number of messages.

Ok, I’ll hold off and see if a Rack deity supplies clarification.

You could probably ask cschol via DM.

And he will tell you in a nice way that you have to remove it.

2 Likes

Was the issue that you logged stuff, or that you logged with WARN severity? Perhaps a diagnostic message with INFO would be OK?

I guess I better fess up. Elastika logs the following at startup. It’s in the VCV Rack library and nobody has complained to me about it so far.

[0.366 info src/elastika.cpp:254 initialize] Mesh has 34 balls, 39 springs.

Let’s just keep a it secret here… don’t tell anybody! :laughing:

I can’t remember. It was a DEBUG statement, but that was close to 3 years ago, so I don’t remember the details.

Well, well… :face_with_monocle:

totally busted!!