Skip to content
Snippets Groups Projects
Commit e1888d3e authored by rswindell's avatar rswindell
Browse files

New library for dealing with the new "logon list" file format (logon.jsonl),

used for "last few callers", "logons today", "logons yesterday", etc.
Methods:
- add([obj]) - optional object to add, auto-filled if not supplied
- get([num], [age]) - optional number of records to return (0:all) and age/days
- maint(backup_level) - daily maintenance

A lot more detail is now recorded for each BBS Logon, so sysops can get
crazy with the information provided in their logon list, if they wish. It is
trivial to add more information (e.g. just add some properties to the add()
argument object).
parent 025ec74a
No related branches found
No related tags found
No related merge requests found
// $Id$
// Library for dealing with the "logon list" (data/logon.jsonl)
"use strict";
function filename(days_ago)
{
if(days_ago > 0)
return system.data_dir + format("logon.%u.jsonl", days_ago - 1);
return system.data_dir + "logon.jsonl";
}
function add(obj)
{
if(!obj)
obj = {};
if(obj.time === undefined)
obj.time = time();
if(obj.user === undefined) {
obj.user = JSON.parse(JSON.stringify(user));
obj.user.limits = undefined;
obj.user.security = undefined;
}
if(obj.node === undefined && js.global.bbs !== undefined)
obj.node = bbs.node_num;
if(obj.total === undefined)
obj.total = system.stats.total_logons;
if(obj.terminal === undefined
&& js.global.console !== undefined) {
obj.terminal = {
desc: console.terminal,
type: console.type,
charset: console.charset,
support: console.term_supports(),
columns: console.screen_columns,
rows: console.screen_rows,
};
}
if(!this.json_lines)
this.json_lines = load({}, "json_lines.js");
return json_lines.add(filename(), obj);
}
function get(num, days_ago)
{
if(!this.json_lines)
this.json_lines = load({}, "json_lines.js");
return json_lines.get(filename(days_ago), num);
}
function maint(backup_level)
{
return file_backup(filename(), backup_level, /* rename: */true);
}
this;
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment