Jump to content
The simFlight Network Forums

Recommended Posts

Posted

Currently, if I choose to log each LUA script individually, I get a constantly appended log file for every script that is running.
Is it possible to add an option like LuaLogClear so that each script run overwrites the Log file instead of appending it?

Thanks!

Posted

Please try the attached version, 7.3.21b.  To use/activate this feature, you need to add the following to the [General] section of your FSUIPC7.ini file:
     LogLuaNew=Yes
I don't think I will add a UI option for this, as I doubt it will be used much - lua logging has worked this way for many years and nobody has requested this before.

Cheers,

John

FSUIPC7.exe

 

Posted

Thank you for this new option. 😀

Would it be possible to also have a possibility not to include a script Lua in the log ?

For example: ipc.log_off () and ipc.log_on (), in the same way as "echo off" in the MSDOS.
Indeed when there is a polling event in a LUA script, the log is polluted by the code corresponding to this.

Posted
8 hours ago, michel78320 said:

Would it be possible to also have a possibility not to include a script Lua in the log ?

For example: ipc.log_off () and ipc.log_on (), in the same way as "echo off" in the MSDOS.
Indeed when there is a polling event in a LUA script, the log is polluted by the code corresponding to this.

Do you mean for this to:
  1. turn off lua debug/trace logging, or
  2. prevent the logging of ipc.log statements?

If 1, then I don't think this is a good idea as  all lua activity, including the polling, should be logged. If you want to control the logging in the script itself, you can use ipc.control with one of the logging settings controls - from the Advanced User guide:

Quote

The following controls manipulate Logging settings without visiting the Logging tab of the options dialogue:

 

    1131 Log set (parameter sets additional logging options*)    1132 Log clear (parameter clears specified logging options*)
    1133 Log toggle (parameter specifies options to be changed*)
             * The bits in the parameter specify the options being set/cleared/toggled.
             (These are in the same order as the list in the Logging tab):

 

                       2^0 1 Weather
                       2^1 2 IPC Writes
                       2^2 4 IPC Reads
                       2^3 8 Buttons and Keys
                       2^4 16 Events (non-axis)
                       2^5 32 Axis events
                       2^6 64 Lua logging to separate files
                       2^7 128 Debug/Trace Lua
                       2^8 256 Log Extras
   

              To clear all logging options, use "Log clear" with parameter 511.

    1134  .Log console on (Note: from 4.859r the focus is restored to FS)

    1135 Log console off
    1136 Log debug (parameter gives debug instructions, for use only under Support direction)
    1137 New log file (close last and start a new one)

 

    1138 Log test options (parameter gives test instructions, for use only under Support direction)

if 2, I don't see  that much need either, although maybe useful to turn off logging statements added for debugging purposes when developing a script, but then you could also remove or comment these out when done.

So I don't think this would really add much.

John

Posted
11 hours ago, John Dowson said:

Do you mean for this to:
  1. turn off lua debug/trace logging, or
  2. prevent the logging of ipc.log statements?

If 1, then I don't think this is a good idea as  all lua activity, including the polling, should be logged. If you want to control the logging in the script itself, you can use ipc.control with one of the logging settings controls - from the Advanced User guide:

Oh, I was thinking of option 1.
"Ipc.log ()"  is a willingness of the developer and I do not think useful to deactivate it.

Yes, I want to control the logging in the script itself, so (as you say) I can use ipc.control with one of the logging settings controls.
I did not have this option in my Advanced User guide (too old).

I will look at this, and will tell you.
I think it will do the job. Thank you.

Posted

No, I am sorry, it is not exactly what I hope : This option regulates all scripts at the same time.

My main Lua script launches several scripts.
Most of them are perfectly ok.
One of them is a polling of my Saitek modules.
When I write a new script, the Saitek script fills the logfile  and I find it difficult to follow the log of my new script.
I would like an option to not put in the log (console and/or file) of one or more script.

Posted
13 hours ago, michel78320 said:

No, I am sorry, it is not exactly what I hope : This option regulates all scripts at the same time.

As does setting the Log -> Lua Plugins option.

13 hours ago, michel78320 said:

My main Lua script launches several scripts.
Most of them are perfectly ok.
One of them is a polling of my Saitek modules.
When I write a new script, the Saitek script fills the logfile  and I find it difficult to follow the log of my new script.
I would like an option to not put in the log (console and/or file) of one or more script.

Why is the saitek script filling the log if you are logging your luas in separate files? If there is a separate script for polling your Saitek devices, this should be logged in a separate script.

You can also start some scripts in debug mode, using the LuaDebug control. There is no ips.runluaDebug function.

Otherwise, you could include the ipcDebug.lua in the scripts you want to debug. This is included in the provided lua example scripts (in your documents folder. If you take a look at that, you can see how the lua debug logging works - by setting hooks.  You could also use this and add your own functions to both set and clear the hooks, and so enable/disable the debug level logging.

I am busy the next few days but I can look into this further next week if needed.

Posted

Thank you for these explanations. I already knew the separate log option.
But that only concerns the log files.
This requires rereading log files.

I find it more pleasant to read live on the console. And this is why I would like to exclude some Lua scripts from the console log.

If this is difficult to achieve, no problem, I manage well with what exists. It's just to save time during my development.
And thank you for listening.

Posted
3 hours ago, michel78320 said:

I find it more pleasant to read live on the console. And this is why I would like to exclude some Lua scripts from the console log.

Ah, ok.... But there are already various ways to do this:
    - run the script you want to log with LuaDebug, and run the others without
    - run without lua logging and add ipc.log statements to the script you want to debug
    - include the ipcDebug.lua script in the lua file you want to debug.

A lua function to control this just doesn't make much sense to me as the current lua log options are global - I think it would confuse people and would eventually result in further support requests, e.g. "why isn't my lua script being logged when I have set Log Lua Plugins?". Better to leave the global options as they are and use something specific (i.e. one of those 3 options mentioned above)  for the script you want to debug.

 

Posted

Thank you for your explanations.

I read once again and carefully all the documents provided with FSUIPC.
Unfortunately, I have a little trouble understanding how to do it.

For example, for the A320 Fenix, I have several Lua scripts, for OVH (VRInsight), FCU (CP-Flight), MCDU (OpenCockpit), Saitek modules. It makes several thousand lines.

I also have a LUA script (cursor.lua) which brings the cursor back to the main MSFS window, to avoid losing control of the aircraft during landing, in case, unfortunately, the cursor goes into a gauge of a secondary screen.
All this works perfectly. So I don't use debug for normal flight.
It slows the scripts far too much.

Sometimes an aircraft update makes one button not to work more in the right way.
In this case, I look at the FSUIPC console during the flight, to see what is happening.
I do not use the log files, because it is not in real time.

It gives me satisfaction. Except that the cursor script, triggered every second, sends thousands of lines on the console.
If I have to change the FSUIPC options, restart and try to recreate the bug, this is not always possible.
So the only thing that bothers me is the log lines on the FSUIPC console that are sent by my "cursor.lua" script.

I do not understand how to get that with the available options (without restarting FSUIPC, and without a permanent trace) :
- In the fsuipc.ini file ?
- Parameter of "ipc.runlua (" cursor.lua" , ????)
- elsewhere.

Could you tell me ? Thanks in advance.

Posted

Once a lua script is running in debug mode, you cam only stop the debug logging by killing the script and running it again. Similarly, if a script is running and you want to start debug logging for it. you need to kill it and restart it in debug mode.
You can assign a button or key press to both Lua <script> and LuaDebug <scriot>. Starting a lua with such a control will kill the script, if already running, and restart it either without or with debugging, depending on the control used.

Other than that, I am not sure what you are asking, If you don't want the cursor.lua script to log lines to the console, don't run it in debug mode and don't set the log option to run all lua scripts in debug mode. If you just want one (or more) scripts ran in debug mode, start those scripts with LuaDebug, or include the ipcDebug.lua script in them, as I have said,.

Posted
39 minutes ago, John Dowson said:

Other than that, I am nit sure what you are asking, If you don't want the cursor.lua script to log lines to the console, don't run it in debig mode and don't set the log option to run all lua scripts in debug mode. If you just want one (or more) scripts ran in debug mode, start those scripts with LuaDebug, or include the ipcDebug.lua sceipt in them, as I have said,.

Exactly that !

But I did not understand what the Debug Mode is, for the lua script.

Where is it in the documentation ?

Posted

"Debug mode" just means that the debug hooks have been activated in the script. This is done by either:
    - setting the Log -> Log Lua Plugins option. Will enable debug mode for all lua scripts started after this option is set
    - starting the script with the LuaDebug control
    - including (i.e. require)  the ipcDebug.lua in the script.

I seem to be saying the same thing again and again. I don't understand what you don't understand...

Please see the FSUIPC Lua Plug-ins document.

Posted
5 minutes ago, michel78320 said:

When I write "ipc.runlua ("my_script.lua", param), what are possible param ?

Whatever you want - this value is just passe to the lua script in the ipcPARAM variable.

Posted
6 minutes ago, michel78320 said:

There is no simple solution for my request.

I am still not 100% sure in what you are trying to achieve.... If you want lua debug logging active in one script only, I have explained how to do that, If you want to be able to turn debug logging on and off in the script itself, this is not possible as things are. However, if you want to do this, you can add two additional functions to the ipcDebug.lua  to add and remove the debug hooks, and then include/require that and use them. You can even use the ipcPARAM parameter to determine if debug logging should be enabled or not when you start the script, if you so wish.

So, anything should be possible really. Just take a look at the ipcDebug.lua script, and look at the lua documentation for the debug.sethook function.

Posted

Yes, I understand all this. My goal is not to develop my code. It works well. I will fly with for weeks, and suddenly, I have something that is wrong. So, I open the console to see what is going on. What is written in the console is sufficient to find what has changed, except that it is saturated by a single Lua script which does not interest me.
And the console continues to fill while I look ...

I therefore look for a way to cut the word to one of the scripts, but without putting others in Debug mode, as long as they work properly.

The debug affects performance. So I don't want it to be active as long as everything works. When something strange arrives, I would like to activate the console, by activating "Lua Logging", without having to kill and relaunch a script, and without having trace of one of the scripts.

I don't know how to do with all these debug options, but I will think about it with the information you gave me.

Posted

To enable debugging in one script, just restart it by using the LuaDebug control.

If you want to be able to turn debug logging on and off in a script without restarting it, add the following code to your lua script:

Quote

function XXtraceXX(event, line)
  local s = debug.getinfo(2).short_src
  ipc.log(s .. ":" .. line)
end

function setDebugMode(param)
  if param == 0 then
     ipc.log("*** Turning Debug mode off")
     debug.sethook()
  else
     ipc.log("*** Turning Debug mode on")
--     debug.sethook(XXhookXX,"cr")
     debug.sethook(XXtraceXX, "l")
  end
end

event.param("setDebugMode")
 

Then, to turn on/off debugging in the script, you can assign a button or key press to the control LuaValue <scriptName> (where <scriptName> is the name of the lua script) with a parameter value of 1 for turning on debug logging, and 0 to turn it off.

You can also change the debug logging function or the type of hook to suit your needs - again, see the ipcDebug.lua script for an additional debug logging function, and see the lua documentation on the debug library and the sethook function.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.