xiaoxiang781216 commented on a change in pull request #3842: URL: https://github.com/apache/incubator-nuttx/pull/3842#discussion_r645458932
########## File path: drivers/syslog/syslog_filechannel.c ########## @@ -108,6 +168,12 @@ FAR struct syslog_channel_s *syslog_file_channel(FAR const char *devpath) syslog_dev_uninitialize(g_syslog_file_channel); } + /* Rotate the log file, if needed. */ + +#ifdef CONFIG_SYSLOG_FILE_ROTATE + log_rotate(devpath); Review comment: > Theoretically you are right. This can happen. > However, in practice this is very rare, and I prefer to keep the simple solution. > It isn't rare, many IoT product will run a long time. > What you describe is a good idea, but I am afraid that it won't work easily/correctly. > There is no easy way to manipulate the log after it is opened without side-effects: The action is simple: 1. Check the total size after writing log 2. close/rename/open file if the limitation reach > > * Either the system will block during the rotation, possibly harming high priority threads. > * Or there will be lost logs. > The rename process for all filesystem implementaiton should be fast and not relate to the file size. > Unfortunately, it is not possible to predict when the rotation will take place. This will have an impact on the real-time behavior of the system. Keeping the rotations during opening only keeps the system predictable. Normally, write data to file isn't simpler than rename a file. So if renaming impact the real-time behaviour very much, write data should have the same impact. If the real-time is a concern, the right approach is: 1. Send the log to ramlog 2. log service read ramlog and write to file -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org