How to use the @hpcc-js/util.scopedLogger function in @hpcc-js/util

To help you get started, we’ve selected a few @hpcc-js/util examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hpcc-systems / Visualization / demos / dashy / src / index.ts View on Github external
import { event as d3Event } from "@hpcc-js/common";
import { Connection, Result } from "@hpcc-js/comms";
import { Dashboard, Dashy, Databomb, ElementContainer, Form, FormField, LogicalFile, RoxieResult, RoxieService, WU, WUResult } from "@hpcc-js/marshaller";
import { Comms } from "@hpcc-js/other";
import { exists, scopedLogger } from "@hpcc-js/util";
import { sample } from "./sample";

const logger = scopedLogger("index.ts");

/* Test race condition  ---
import { hookSend, IOptions, ResponseType, SendFunc } from "@hpcc-js/comms";
let delay = 0;
const origSend: SendFunc = hookSend(function mySend(opts: IOptions, action: string, request: any, responseType: ResponseType) {
    return new Promise((resolve, reject) => {
        origSend(opts, action, request, responseType).then(response => {
            delay += 1000;
            if (delay > 5000) delay = 0;
            setTimeout(() => {
                resolve(response);
            }, delay);
        });
    });
});
*/
github hpcc-systems / Visualization / tests / test-comms / src / ecl / workunit.spec.ts View on Github external
import { expect } from "chai";

import { Workunit } from "@hpcc-js/comms";
import { scopedLogger } from "@hpcc-js/util";
import { ESP_URL, isTravis } from "../testLib";

const logger = scopedLogger("test/workunit");
const WUID = "W20170510-114044";

describe("test/esp/ecl/Workunit", function () {
    this.timeout(5000);
    describe("simple life cycle", function () {
        let wu1: Workunit;
        it("creation", function () {
            return Workunit.create({ baseUrl: ESP_URL }).then((wu) => {
                expect(wu).exist;
                expect(wu.Wuid).exist;
                wu1 = wu;
                return wu;
            });
        });
        it("update", function () {
            return wu1.update({
github hpcc-systems / Visualization / packages / comms / src / clienttools / eclcc.ts View on Github external
import * as cp from "child_process";
import * as fs from "fs";
import * as os from "os";
import * as path from "path";
import * as tmp from "tmp";

import { exists, scopedLogger, xml2json, XMLNode } from "@hpcc-js/util";
import { attachWorkspace, Workspace } from "./eclMeta";

const logger = scopedLogger("clienttools/eclcc");
const exeExt = os.type() === "Windows_NT" ? ".exe" : "";

export class Version {
    readonly prefix: string = "";
    readonly major: number = 0;
    readonly minor: number = 0;
    readonly patch: number = 0;
    readonly postfix: string = "";

    constructor(build: string) {
        const parts = build.split(" ");
        if (parts.length) {
            const match = /(?:(\w+)_)?(\d+)\.(\d+)\.(\d+)(?:-(.*))?/.exec(parts[parts.length - 1]);
            if (match) {
                this.prefix = match[1] || "";
                this.major = +match[2] || 0;
github hpcc-systems / Visualization / packages / marshaller / src / dashy.ts View on Github external
import { JSEditor, JSONEditor } from "@hpcc-js/codemirror";
import { PropertyExt, Utility, Widget } from "@hpcc-js/common";
import { DDL1, ddl2Schema, upgrade } from "@hpcc-js/ddl-shim";
import { DatasourceTable } from "@hpcc-js/dgrid";
import { Graph } from "@hpcc-js/graph";
import { PropertyEditor } from "@hpcc-js/other";
import { CommandPalette, CommandRegistry, ContextMenu, SplitPanel, TabPanel } from "@hpcc-js/phosphor";
import { scopedLogger } from "@hpcc-js/util";
import { Activity, DatasourceAdapt } from "./ddl2/activities/activity";
import { Dashboard, IDashboardPersist } from "./ddl2/dashboard";
import { DDLEditor } from "./ddl2/ddleditor";
import { GraphAdapter } from "./ddl2/graphadapter";
import { Element, ElementContainer } from "./ddl2/model";

const logger = scopedLogger("marshaller/dashy");

import "../src/dashy.css";

class Palette extends PropertyExt {
    constructor() {
        super();
    }
}
Palette.prototype._class += " Palette";
interface Palette {
    paletteID(): string;
    paletteID(_: string): this;
    colors(): { [color: string]: string[] };
    colors(_: { [color: string]: string[] }): this;
}
Palette.prototype.publish("paletteID", "", "string", "ID", null, { optional: true });
github hpcc-systems / Visualization / packages / marshaller / src / ddl2 / ddl.ts View on Github external
import { DatasourceRef, DatasourceRefType, DatasourceType } from "./activities/datasource";
import { DSPicker } from "./activities/dspicker";
import { Filters } from "./activities/filter";
import { Form } from "./activities/form";
import { GroupBy } from "./activities/groupby";
import { Limit } from "./activities/limit";
import { LogicalFile } from "./activities/logicalfile";
import { Mappings, Project } from "./activities/project";
import { Param, RoxieResult, RoxieResultRef, RoxieService } from "./activities/roxie";
import { Sort } from "./activities/sort";
import { WU, WUResult, WUResultRef } from "./activities/wuresult";
import { Dashboard } from "./dashboard";
import { Element, ElementContainer } from "./model/element";
import { Visualization } from "./model/visualization";

const logger = scopedLogger("marshaller/ddl2/ddl");

type DatasourceRefTypeMap = { [key: string]: DatasourceRefType };
type ServerRefTypeMap = { [key: string]: { ds: DatasourceType, result: DatasourceRefTypeMap } };

class DDLDatasourceAdapter {
    private _dsDedup: ServerRefTypeMap;

    constructor() {
    }

    clear() {
        this._dsDedup = {};
    }

    id(dsT: DatasourceType): string {
        if (dsT instanceof WU) {
github hpcc-systems / Visualization / packages / comms / src / clienttools / eclMeta.ts View on Github external
import * as fs from "fs";
import * as path from "path";

import { Dictionary, DictionaryNoCase, find, SAXStackParser, scopedLogger, XMLNode } from "@hpcc-js/util";
import { ClientTools, locateClientTools } from "./eclcc";

const logger = scopedLogger("clienttools/eclmeta");

export interface IFilePath {
    scope: ECLScope;
}

const _inspect = false;
function inspect(obj: any, _id: string, known: any) {
    if (_inspect) {
        for (const key in obj) {
            const id = `${_id}.${key}`;
            if (key !== "$" && known[key] === undefined && known[key.toLowerCase() + "s"] === undefined) {
                logger.debug(id);
            }
        }
        if (obj.$) {
            inspect(obj.$, _id + ".$", known);
github hpcc-systems / Visualization / demos / dashy / lib-umd / index.js View on Github external
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var comms_1 = require("@hpcc-js/comms");
    var marshaller_1 = require("@hpcc-js/marshaller");
    var other_1 = require("@hpcc-js/other");
    var util_1 = require("@hpcc-js/util");
    var logger = util_1.scopedLogger("index.ts");
    var App = /** @class */ (function () {
        function App(placeholder) {
            this._dashy = new marshaller_1.Dashy();
            this._dashy
                .target(placeholder)
                .render();
            this.parseUrl();
        }
        App.prototype.parseUrl = function () {
            var _this = this;
            var _url = new other_1.Comms.ESPUrl().url(document.URL);
            if (_url.param("Wuid")) {
                logger.debug("WU Params:  " + _url.params());
                var baseUrl_1 = _url.param("Protocol") + "://" + _url.param("Hostname") + ":" + _url.param("Port");
                logger.debug(baseUrl_1);
                var result = new comms_1.Result({ baseUrl: baseUrl_1 }, _url.param("Wuid"), _url.param("ResultName"));
github hpcc-systems / Visualization / apps / legacyDash / src / app.ts View on Github external
import { DDLEditor, JSEditor, JSONEditor } from "@hpcc-js/codemirror";
import { d3SelectionType, HTMLWidget } from "@hpcc-js/common";
import { Result } from "@hpcc-js/comms";
import { ddl2Schema, upgrade } from "@hpcc-js/ddl-shim";
import { Dashboard, ElementContainer } from "@hpcc-js/marshaller";
import { Comms } from "@hpcc-js/other";
import { DockPanel, SplitPanel } from "@hpcc-js/phosphor";
import { scopedLogger } from "@hpcc-js/util";

const logger = scopedLogger("app");

export class App extends DockPanel {
    private _url = new Comms.ESPUrl().url(document.URL);
    private _ddlv1 = new JSONEditor();
    private _ddlv2_upgraded = new JSONEditor();
    private _elementContainer: ElementContainer = new ElementContainer();
    private _dashboard = new Dashboard(this._elementContainer);
    private _ddlv2 = new JSONEditor();
    private _schema = new JSONEditor();

    constructor() {
        super();
        this.parseParams();
        this._schema.json(ddl2Schema);
    }
github hpcc-systems / Visualization / packages / comms / src / ecl / workunit.ts View on Github external
import { utcFormat, utcParse } from "d3-time-format";
import { IConnection, IOptions } from "../connection";
import { ESPExceptions } from "../espConnection";
import { SMCActivity } from "../services/wsSMC";
import * as WsTopology from "../services/wsTopology";
import * as WsWorkunits from "../services/wsWorkunits";
import { createGraph, createXGMMLGraph, ECLGraph, GraphCache, ScopeGraph, XGMMLGraph, XGMMLVertex } from "./graph";
import { Resource } from "./resource";
import { Result, ResultCache } from "./result";
import { BaseScope, Scope } from "./scope";
import { SourceFile } from "./sourceFile";
import { Timer } from "./timer";

const formatter = utcFormat("%Y-%m-%dT%H:%M:%S.%LZ");
const parser = utcParse("%Y-%m-%dT%H:%M:%S.%LZ");
const logger = scopedLogger("workunit.ts");

const WUStateID = WsWorkunits.WUStateID;

export class WorkunitCache extends Cache<{ BaseUrl: string, Wuid: string }, Workunit> {
    constructor() {
        super((obj) => {
            return `${obj.BaseUrl}-${obj.Wuid}`;
        });
    }
}
const _workunits = new WorkunitCache();

export interface DebugState {
    sequence: number;
    state: string;
    [key: string]: any;