logIO 1.0.0 is released.
FYI I have created a separate subject for questions/comments and thanks !!
Not sure what is the right practice, adding it here or creating a new topic.
Hi @greengolfer
I'll look into both things.
Issue with button should be fixed in deployed version 1.0.1.
Regarding the dynamic filenames - how many different files are we talking here for your case, 10, 100, 1000?
Sadly this is not supported by winston library I'm using although that doesn't mean it's not possible. I'd had to create a new instance of logger for each dynamic filename but I'm a bit concerned about potential memory leaks if we're talking about hundreds of different files.
First, thank you for node-red-log-io (node) - Node-RED it looks really promising.
Being, so far, a rather heavy user of flogger I am giving it a go.
It doesn't seem to be possible to set dynamically the log file name with a msg. Have I missed something ?
I log messages out of mqtt in nodes. I need to split the logging using part of the topic (slightly more subtle than that, but, in short this is what I need). At the moment, it seems that I can't.
If the logIO node is active and then greying the components button, it looks like one must deploy the node for the log to stop, unlike the usual debug.
Then, if I want to re-enable logging, it looks like I need to deploy in full for the change to be effective. Only deploying the changed node (here logIO) is not enough.
@greengolfer thanks for letting me know.
Let's continue debate here: [Announce] node-red-log-io
I merged the post to keep things tidy.
——
Regarding the dynamic filenames - how many different files are we talking here for your case, 10, 100, 1000?
——
In the range of 10. Not much.
Thanks
@greengolfer what you requested was added in version 1.1.0 and sample flow was added to examples.
Specify fileName
Bellow applies if output is set to File
.
By default, logIO will log messages to file name specified in logger properties. But you can also define file name dynamically through incoming message.
To do so, incoming message should have a _logIO_ object with key fileName
set to the name of desired file.
{
"payload" : "your payload",
"topic": "your topic",
"_logIO_" : { "fileName": "logIO-%DATE%.error", logLevel: "error" }
}
Specify dirName
Bellow applies if output is set to File
.
By default, logIO will log messages to directory specified in logger properties. But you can also define directory dynamically through incoming message.
To do so, incoming message should have a _logIO_ object with key dirName
set to the directory name.
{
"payload" : "your payload",
"topic": "your topic",
"_logIO_" : { "dirName": "/var/log/node-red/errors", "fileName": "logIO-%DATE%.error", logLevel: "error" }
}
I should also add additional warning in case logging to files:
Have in mind that if you delete of manually save the file that logIO is writing logs to, it might not be recreated. Watcher observing the file changes in not 100% reliable, thus avoid modifying/deleting files that are currently in use by logIO.
If you delete the active log file and it's not automatically recreated, you'll have to redeploy the flow.
Just tried 1.1.1. Great stuff for the filename ! Works perfectly.
There is still something not quite right in the on/off using the component button.
Here is what I can see:
- import example and deploy. Most of the case I am using "Modified nodes" deployment option.
- Inject, log perfectly
- tick the component to turn off logging. Status is changed.
- Inject, no log. What is expected
- deploy using modified nodes
- Inject, no log. What is expected
- tick the component to turn on logging.
- Deploy using modified nodes (important !!) Status is changed.
- Inject, no log. NOT what should happen.
For the last three actions, If I do the exact same sequence but use Full to deploy then:
- tick the component to turn on logging.
- Deploy using Full, Status is changed.
- Inject, see log. What is expected.
So, the behaviour is different when deploying Full or Modified Nodes.
Thanks !!
Can you share an example of your flow please. What exactly you mean by modified nodes?
I'll definitely take a look, just trying to understand for easier reproduction.
Thanks. Was not aware of this one
I'll take a look and deploy a fix when ready.
Something else
I am using the dynamic filename option/
If I set msg.logIO to :
{
"fileName": gb & ".json",
"dirName": "/log",
"logLevel": "info"
}
using jsonata, msg.gb is a string.
There is no DATE defined in the filename.
I can see that the DATE, in the format defined in the setup node of the log, is added at the end of the filename.
So the effective filename becomes: mystring.json.20250121
It is no really an issue, but, it is unexpected.
So, I changed to :
{
"fileName": gb & "-%DATE%.json",
"dirName": "/log",
"logLevel": "info"
}
I get mystring-2025-01-21.json
Like that the json extension is kept.
Please check the button behavior along with deploy of modified nodes only (version 1.1.2).
Should be fixed and now also status on the node should reflect the change immediately and not only upon save (to indicate if logging is active or paused).
I'll check tomorrow about %DATE% replacement. This is added by 3rd party lib so I'll have to check if something can be done.
I'll check and do one of these things:
- if
%DATE%
placeholder is omitted in file name, it should not be appended to the end of the file - if that will not be possible, document this behavior.
Works perfectly !
Really great tool.
Fixed in version 1.1.3. If %DATE%
is missing in your filename, default date format won't be appended to the end of it.
Hi, this looks promising. Particulaly interested in inline debug and file logging rolloed into one.
i just tried it out and it crashed my instance...
22 Jan 10:26:15 - [error] [function:Store Functions] TypeError: Cannot read properties of undefined (reading 'timestampFormat')
22 Jan 10:26:15 - [info] Started flows
Shelly gen1 server is listening on port 20001
2025-01-22 10:26:15.938 FATAL Logger Unhandled error detected: EACCES: permission denied, open '../logIO-2025-01-22.log'
22 Jan 10:26:15 - [red] Uncaught Exception:
22 Jan 10:26:15 - [error] Error: EACCES: permission denied, open '../logIO-2025-01-22.log'
I fully appreciate this could be down to settings I entered but an important point of node-red nodes is that you should handle all errors and not permit it to crash node-red.
Also note, this has caused node-red to bootloop (must be trying to do whatever it is doing on instantiation) - i had to restart in --safe
mode.
This is the flow I created. It is running on Node-RED 4.0.8, Node v18, on a RPi. Hopefully it will help you debug and handle the error?
[{"id":"447eae4d60cc3635","type":"logIO","z":"90e2df527c725ffb","name":"logIO 1","active":true,"logger":"41c90633a0d14285","complete":"payload","targetType":"msg","logIOMode":"wired","logIOScope":"IO","autoStart":true,"scope":[],"x":560,"y":620,"wires":[]},{"id":"adab22809f7213b2","type":"inject","z":"90e2df527c725ffb","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":400,"y":620,"wires":[["447eae4d60cc3635"]]},{"id":"41c90633a0d14285","type":"logIO-logger","name":"file-debug","logLevel":"debug","isTimestampUTC":false,"logMeta":"all","logMetaOptions":"","logOutput":"file,nr-debugger","fileFileName":"logIO-%DATE%.log","fileDirName":"../","fileDatePattern":"YYYY-MM-DD","fileIsJsonFormat":false,"fileZippedArchive":false,"fileMaxSize":"1","fileMaxSizeUnit":"m","fileMaxFiles":"3","fileMaxFilesUnit":"","consoleIsJsonFormat":false,"elkUrl":"http://localhost:9200","elkIndex":"node-red"}]
Will check yes, tnx for the logs.