<commit_before>var mms = require('./mms');
var common = require('./common');

//
//  The optimist argv array, propagated from the caller
//
var argv;

//
//  The MMS Session object propagated from the caller
//
var session;

//
//  The maximum number of log rows we try to get in one blast
//
var ROW_LIMIT = 200;

//
//  In "tail" mode, this is the time between attempts to get more log messages
//
var refreshIntervalInMs;

//
//  In "tail" mode this is the timestamp of the last read message, which we can use to
//  poll for the next set as it comes in.
//
var lastTime = 0;

//
//  The array of names of the loggers from which we are reading. If null it means to get message from all logger sources.
//
var loggerNameList = [];

//
//  The array of log level names in which we are interested; if null it means we want all levels of log messages
//
var logLevelList = [];

//
//  The REST query object we will build in memory to get the desired set of log records
//
var queryObject = null;

//
//  By default we hide any of these 'noise' messages that clutter the log. If the caller specified --showNoise
//  we won't hide these.
//
var noise = [
                'REST REQUEST: {"op":"INVOKE","targetType":"CdmMessage","name":"fetchActiveMessages"} REST RESPONSE: SUCCESS',
                'REST REQUEST: {"op":"SELECT","targetType":"CdmUser","properties":[],"where":{"username":"mms"}} REST RESPONSE: SUCCESS'
            ]


exports.showLog = function showLog(startTime,endTime)
{
    argv = common.global.argv;
    session = common.global.session;
    refreshIntervalInMs = argv.refreshInterval;

    var obj = new Object();

    obj.op = "SELECT";
    obj.targetType = "CdmLog";
    obj.properties = ["time","message","tenant","level","logger","username"];
    obj.options = new Object();
    obj.options.limit = ROW_LIMIT;
    obj.options.startAt = 0;

    obj.where = new Object();

    var dt;

    if (argv.tail)
    {
        if (startTime)<commit_msg>Fix old bug in emote log; log records not being sorted by time<commit_after>var mms = require('./mms');
var common = require('./common');

//
//  The optimist argv array, propagated from the caller
//
var argv;

//
//  The MMS Session object propagated from the caller
//
var session;

//
//  The maximum number of log rows we try to get in one blast
//
var ROW_LIMIT = 200;

//
//  In "tail" mode, this is the time between attempts to get more log messages
//
var refreshIntervalInMs;

//
//  In "tail" mode this is the timestamp of the last read message, which we can use to
//  poll for the next set as it comes in.
//
var lastTime = 0;

//
//  The array of names of the loggers from which we are reading. If null it means to get message from all logger sources.
//
var loggerNameList = [];

//
//  The array of log level names in which we are interested; if null it means we want all levels of log messages
//
var logLevelList = [];

//
//  The REST query object we will build in memory to get the desired set of log records
//
var queryObject = null;

//
//  By default we hide any of these 'noise' messages that clutter the log. If the caller specified --showNoise
//  we won't hide these.
//
var noise = [
                'REST REQUEST: {"op":"INVOKE","targetType":"CdmMessage","name":"fetchActiveMessages"} REST RESPONSE: SUCCESS',
                'REST REQUEST: {"op":"SELECT","targetType":"CdmUser","properties":[],"where":{"username":"mms"}} REST RESPONSE: SUCCESS'
            ]


exports.showLog = function showLog(startTime,endTime)
{
    argv = common.global.argv;
    session = common.global.session;
    refreshIntervalInMs = argv.refreshInterval;

    var obj = new Object();

    obj.op = "SELECT";
    obj.targetType = "CdmLog";
    obj.properties = ["time","message","tenant","level","logger","username"];
    obj.options = new Object();
    obj.options.limit = ROW_LIMIT;
    obj.options.startAt = 0;
    obj.options.sort = {time:1};

    obj.where = new Object();

    var dt;

    if (argv.tail)
    {
        if (startTime)
{'fraction_non_alphanumeric': 0.12705530642750373, 'fraction_numerical': 0.0027404085700049826, 'mean_word_length': 2.9208984375, 'pattern_counts': {'":': 16, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1249460', 'n_tokens_mistral': 1236, 'n_tokens_neox': 1190, 'n_words': 467}