This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

eventlog.lp
#9
Unfortunately back to nothing again. BUt no errors in Network Window anymore which is good I think.

This is the Common Function script:-
function eventlog(text)
  local max = 1000 -- max number of entries
  -- add formatted date
  text = os.date('%a %d/%m/%Y %T ') .. text

  storage.exec('lpush', 'eventlog5', text)
  storage.exec('ltrim', 'eventlog5', 0, max - 1)
end

This is what's in the eventlog.lp
<?
require('apps')
items = storage.exec('lrange', 'eventlog5', 0, 999)
?>
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Event log</title>
  <script src="/user/jquery.js.gz"></script>
  <link rel="stylesheet" href="/user/bootstrap.css">
</head>
<body>
<script>
$(function() {
  var items = <? json.write(items) ?>
    , container = $('.container')
    , header;

  $.each(items, function(index, item) {
    var chunks = item.split(' ')
      , newheader = chunks.shift() + ' ' + chunks.shift();

    // output data header each time it changes
    if (newheader != header) {
      header = newheader;
      $('<h3></h3>').text(header).appendTo(container);
    }

    // output log entry
    $('<p></p>').text(chunks.join(' ')).appendTo(container);
  });
});
</script>
<div class="container"></div>
</body>
</html>

For testing used in Event Script
eventlog(event.getvalue())
log(io.ls('/data/apps/store/user'))
log(storage.exec('lrange', 'eventlog5', 0, 999))

This gives back in log:-

Event for 0/1/0 16.06.2025 14:43:45
* table:
[1]
  * string: eventlog.lp
[2]
  * string: bootstrap.css.gz
[3]
  * string: jquery.js.gz
[4]
  * string: bootstrap.css
[5]
  * string: log.txt
Event for 0/1/0 16.06.2025 14:43:45
* table:
[1]
  * string: Mon 16/06/2025 14:43:45 7
[2]
  * string: Mon 16/06/2025 14:12:39 239
[3]
  * string: Mon 16/06/2025 14:12:30 150
Reply


Messages In This Thread
eventlog.lp - by sjfp - 15.06.2025, 13:02
RE: eventlog.lp - by admin - 16.06.2025, 06:45
RE: eventlog.lp - by sjfp - 16.06.2025, 07:51
RE: eventlog.lp - by admin - 16.06.2025, 07:54
RE: eventlog.lp - by sjfp - 16.06.2025, 10:25
RE: eventlog.lp - by admin - 16.06.2025, 12:17
RE: eventlog.lp - by sjfp - 16.06.2025, 13:25
RE: eventlog.lp - by admin - 16.06.2025, 13:26
RE: eventlog.lp - by sjfp - 16.06.2025, 13:51
RE: eventlog.lp - by admin - 16.06.2025, 13:54
RE: eventlog.lp - by sjfp - 16.06.2025, 14:12
RE: eventlog.lp - by admin - 16.06.2025, 14:15
RE: eventlog.lp - by sjfp - 16.06.2025, 14:49

Forum Jump: