<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Mark, Steve,<br>
<br>
thanks for the test & workaround.<br>
<br>
Yes, the syslog can better be distributed internally by the
console system. The "tail" command is also intended for general
debugging/monitoring of files. I thought it would be straight
forward to implement, but another issue/idea turned up we should
discuss -- I'll follow up on that after work.<br>
<br>
Regards,<br>
Michael<br>
<br>
<br>
Am 10.01.2018 um 01:07 schrieb Mark Webb-Johnson:<br>
</div>
<blockquote type="cite"
cite="mid:B0906432-9A79-4539-BDDB-7EEE6FDC6447@webb-johnson.net">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
Nope:
<div class=""><br class="">
</div>
<div class="">Here is /store:</div>
<div class=""><br class="">
</div>
<blockquote style="margin: 0px 0px 0px 40px; border: none;
padding: 0px;" class="">
<div class="">OVMS > log file /store/log.txt</div>
<div class="">...</div>
<div class="">I (37670) simcom: State: Enter PoweringOn state</div>
<div class="">I (37670) simcom: Power Cycle</div>
<div class="">OVMS > vfs stat /store/log.txt</div>
<div class="">File /store/log.txt size is 0 and digest
d41d8cd98f00b204e9800998ecf8427e</div>
<div class="">OVMS > log file</div>
<div class="">Closed log file</div>
<div class="">OVMS > vfs stat /store/log.txt</div>
<div class="">File /store/log.txt size is 1176 and digest
b15515a15edeb75d04a2767ba66a721d</div>
</blockquote>
<div class="">
<div><br class="">
</div>
<div>And here is /sd:</div>
<div><br class="">
</div>
</div>
<blockquote style="margin: 0px 0px 0px 40px; border: none;
padding: 0px;" class="">
<div>
<div>OVMS > log file /sd/log.txt</div>
<div>I (15494) simcom: State timeout, transition to 1</div>
<div>I (15494) simcom: State: Enter CheckPowerOff state</div>
<div>OVMS > vfs stat /sd/log.txt</div>
<div>File /sd/log.txt size is 0 and digest
d41d8cd98f00b204e9800998ecf8427e</div>
<div>OVMS > log file</div>
<div>Closed log file</div>
<div>OVMS > vfs stat /sd/log.txt</div>
<div>File /sd/log.txt size is 122 and digest
ae18d2d2ed63b5dd2381b5bf11d1779d</div>
</div>
</blockquote>
<div class="">
<div><br class="">
</div>
<div>Seems to be the FAT filesystem itself.</div>
</div>
<div><br class="">
</div>
<div><span id="x-apple-selection:end"></span>The vfs layer only
seems to support a fsync operation, but no fflush. I’m guessing
fflush just flushes the FILE buffers, but doesn’t actually sync
that to disk. Adding 'fsync(fileno(ovms_log_file));’ after
'fflush(ovms_log_file);’ in ConsoleAsync::ConsoleLogger of
main/console_async.cpp seems to resolve this:</div>
<div><br class="">
</div>
<blockquote style="margin: 0 0 0 40px; border: none; padding:
0px;" class="">
<div>
<div>OVMS > log file /store/log.txt</div>
<div>OVMS > vfs stat /store/log.txt</div>
<div>File /store/log.txt size is 1176 and digest
b15515a15edeb75d04a2767ba66a721d</div>
<div>I (15450) simcom: State timeout, transition to 13</div>
<div>I (15620) simcom: State: Enter PoweredOff state</div>
<div>OVMS > vfs stat /store/log.txt</div>
<div>File /store/log.txt size is 1296 and digest
96221e6daf7258b6e2c0d9eb4a92cad3</div>
</div>
</blockquote>
<div><br class="">
</div>
<div>There is also a separate issue of multi-line messages not
being logged correctly (LF -> “|" translation). I’ve pushed
both fixes to the remotes/origin/for-v3.0 branch Steve and I are
working on for v3.0. Haven’t tested in 2.1 master, but it will
probably work there if you want to merge back to master.</div>
<div><br class="">
</div>
<div>All that said, I think Steve is correct. A tail function
(although useful) is not the best way of doing this particular
thing. Better to have a ‘log monitor yes/no’ command that sets a
flag on the current console (presumably in OvmsWriter like the
m_issecure flag). If set, then log messages are shown on that
console. Perhaps default to ‘yes’ for async console, and ‘no’
for the others.</div>
<div><br class="">
</div>
<div>Now SD CARD support is coming, anybody want to step forward
and extend components/can to support CAN bus logging to a file
(in crtd format, or perhaps support one or two popular formats)?
Implementation would be in class canbus, very similar to
m_trace; just need to have a FILE* m_log and appropriate
commands / logging of packet write/read in the same place that
trace does it.</div>
<div><br class="">
</div>
<div>Regards, Mark.</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 10 Jan 2018, at 7:28 AM, Stephen Casner <<a
href="mailto:casner@acm.org" class=""
moz-do-not-send="true">casner@acm.org</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Michael,<br class="">
<br class="">
I think we can do better than "tail" command. The design
for printing<br class="">
log messages is prepared to print on all registered
consoles. We have<br class="">
restricted the console_logger() function to just output on
the async<br class="">
console out of concernt that sending output to the remote
consoles<br class="">
might be too much of a burden. But if that is what's
desired for a<br class="">
particular user's scenario, then what we should do is to
add a command<br class="">
to direct the output to all consoles.<br class="">
<br class="">
--
Steve<br class="">
<br class="">
On Wed, 10 Jan 2018, Michael Balzer wrote:<br class="">
<br class="">
<blockquote type="cite" class="">Mark,<br class="">
<br class="">
I've built a simple "tail" command to follow the file
log on the telnet console.<br class="">
<br class="">
Unfortunately -- with v2.1 -- the fflush() on the log
file doesn't work as expected, the file contents will
not be updated until I close the file.<br class="">
<br class="">
Is that issue solved with v3.x?<br class="">
<br class="">
Regards,<br class="">
Michael<br class="">
<br class="">
<br class="">
Am 08.01.2018 um 07:28 schrieb Mark Webb-Johnson:<br
class="">
<blockquote type="cite" class="">I've restructured the
log commands a bit:<br class="">
<br class="">
* The old "level <severity>" command has moved
to "log level <severity>"<br class="">
<br class="">
* A new "log file <path>" command has been
added. For example "log file /sd/log.txt" will mean
that anything that gets logged to the console will
also get<br class="">
appended to /sd/log.txt as well, until reboot. You
can use /sd (if SD CARD is working for you), or /store
(but take care - that is system flash).<br class="">
<br class="">
* You should be able to hook this in at the
"sd.mounted" event script, to turn on logging to sd
card on boot (again, if SD CARD is working for you).<br
class="">
<br class="">
<br class="">
Enjoy, Mark<br>
</blockquote>
</blockquote>
</div>
</div>
</blockquote>
</div>
</blockquote>
<br>
<pre class="moz-signature" cols="144">--
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
</pre>
</body>
</html>