Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tailing on non (unusual) flushing loggers #334

Closed
vlovo opened this issue Aug 22, 2018 · 9 comments
Closed

tailing on non (unusual) flushing loggers #334

vlovo opened this issue Aug 22, 2018 · 9 comments

Comments

@vlovo
Copy link
Contributor

vlovo commented Aug 22, 2018

this is taken over from #331
I use log4cxx as a logging framework. It turns out that flushing do not operate as expected.
When tailing the file in DebugView++ the FILE_NOTIFY_CHANGE_SIZE event will never be invoked. It will be invoked if you hit F5 in file explorer or if you start Baretail.exe (https://www.baremetalsoft.com/baretail/) alongside to tail the same file.
I also made a test app with log4cxx and I try to forced to do an immediate flush by using the approbiate API function (appender->setImmediateFlush(true); for the record), but the behaviour
do not change. So it is supposed to be a bug in log4cxx or they forget to remove API function, because the never want to flush...

So I came along with a workaround, because I noticed by quering the filesize periodically invokes the FILE_NOTIFY_CHANGE_SIZE in DebugView++.
So if you add in FileReader ctor the following ( just to sketch the idea roughly..) :

std::thread t([this]()
	{
		namespace fs = std::experimental::filesystem;
		fs::path p(m_filename);
		size_t s = 0;
		while (1)
		{
			s = fs::file_size(p);
			Sleep(40);
		}
		return (s);
		});

	t.detach();

it turns out tailing/autoscroll operation works again.

@janwilmans
Copy link
Member

Thanks! That sounds very interesting, I will test this and make it part of debugview++

@vlovo
Copy link
Contributor Author

vlovo commented Aug 22, 2018

NFlog4cxx64.zip
Attached you find the sample app as executeable , with log4cxx DLL for your convenience .....

@janwilmans
Copy link
Member

I tried your test and see exactly what you mean, very interesting.

@janwilmans
Copy link
Member

tail for win32 and notepad++ seems to have solved this the same way you suggest.
notepad-plus-plus/notepad-plus-plus#3142

@janwilmans
Copy link
Member

I tested your proposal, however it does not work, fs::file_size(p); is not triggering the FILE_NOTIFY_CHANGE_SIZE... I do see that right-clicking the log-file or clicking 'properties' in explorer does trigger FILE_NOTIFY_CHANGE_SIZE... looking for better ways...

@janwilmans
Copy link
Member

please try this pre-release version
https://github.com/CobaltFusion/DebugViewPP/releases/tag/v1.8.0.27

@vlovo
Copy link
Contributor Author

vlovo commented Aug 23, 2018

Sorry ,your are right ; I also did auto res = Win32::WaitForAnyObject(waitHandles, 10000); instead waiting INFINITE. This might solve kind of starting problem....

@vlovo
Copy link
Contributor Author

vlovo commented Aug 24, 2018

I testeted v1.8.0.27 👍
works with test and real apps !

@janwilmans
Copy link
Member

good to hear. however, I'm not really keen on the current solution, its polling the filesize every 500ms, which means it is doing more work then should be needed and the timestamps (in debugview) are at best 500ms-accurate, which is quite bad compared to the normal ~microsecond accuracy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants