How to use the node-opcua-debug.make_errorLog function in node-opcua-debug

To help you get started, we’ve selected a few node-opcua-debug 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 node-opcua / node-opcua / packages / node-opcua-address-space / src / alarms_and_conditions / ua_condition_base.ts View on Github external
import { TimeZoneDataType } from "node-opcua-types";
import { DataType, Variant, VariantLike } from "node-opcua-variant";
import { ConditionType, Namespace, SessionContext, UAEventType, UAMethod, UAVariableT } from "../../source";
import { ConditionInfoOptions } from "../../source/interfaces/alarms_and_conditions/condition_info_i";
import { AddressSpacePrivate } from "../address_space_private";
import { BaseNode } from "../base_node";
import { UAObject } from "../ua_object";
import { UAObjectType } from "../ua_object_type";
import { _install_TwoStateVariable_machinery, UATwoStateVariable } from "../ua_two_state_variable";
import { UAVariable } from "../ua_variable";
import { BaseEventType } from "./base_event_type";
import { ConditionInfo } from "./condition_info";
import { ConditionSnapshot } from "./condition_snapshot";

const debugLog = make_debugLog(__filename);
const errorLog = make_errorLog(__filename);
const doDebug = checkDebugFlag(__filename);

export interface UAConditionBase extends BaseEventType {

    on(
      eventName: string,
      eventHandler: (...args: any[]) => void
    ): this;

    // -- Events
    on(
      eventName: "addComment",
      eventHandler: (
        eventId: Buffer | null,
        comment: LocalizedText,
        branch: ConditionSnapshot
github node-opcua / node-opcua / packages / node-opcua-server / source / server_engine.ts View on Github external
SessionSecurityDiagnosticsDataType,
  TimeZoneDataType,
  WriteValue
} from "node-opcua-types";
import { DataType, isValidVariant, Variant, VariantArrayType } from "node-opcua-variant";

import { HistoryServerCapabilities, HistoryServerCapabilitiesOptions } from "./history_server_capabilities";
import { MonitoredItem } from "./monitored_item";
import { OperationLimits, ServerCapabilities, ServerCapabilitiesOptions } from "./server_capabilities";
import { ServerSidePublishEngine } from "./server_publish_engine";
import { ServerSidePublishEngineForOrphanSubscription } from "./server_publish_engine_for_orphan_subscriptions";
import { ServerSession } from "./server_session";
import { Subscription } from "./server_subscription";

const debugLog = make_debugLog(__filename);
const errorLog = make_errorLog(__filename);
const doDebug = checkDebugFlag(__filename);

function shutdownAndDisposeAddressSpace(this: ServerEngine) {
  if (this.addressSpace) {
    this.addressSpace.shutdown();
    this.addressSpace.dispose();
    delete this.addressSpace;
  }
}

// binding methods
function getMonitoredItemsId(
  this: ServerEngine,
  inputArguments: any,
  context: SessionContext,
  callback: any
github node-opcua / node-opcua / packages / node-opcua-server / source / server_end_point.ts View on Github external
} from "node-opcua-crypto";
import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";
import { getFullyQualifiedDomainName, resolveFullyQualifiedDomainName } from "node-opcua-hostname";
import {
    fromURI,
    MessageSecurityMode,
    SecurityPolicy,
    ServerSecureChannelLayer, ServerSecureChannelParent,
    toURI
} from "node-opcua-secure-channel";
import { UserTokenType } from "node-opcua-service-endpoints";
import { EndpointDescription } from "node-opcua-service-endpoints";
import { ApplicationDescription } from "node-opcua-service-endpoints";

const debugLog = make_debugLog(__filename);
const errorLog = make_errorLog(__filename);
const doDebug = checkDebugFlag(__filename);

const default_transportProfileUri = "http://opcfoundation.org/UA-Profile/Transport/uatcp-uasc-uabinary";

function dumpChannelInfo(channels: ServerSecureChannelLayer[]): void {

    function dumpChannel(channel: ServerSecureChannelLayer): void {

        console.log("------------------------------------------------------");
        console.log("            channelId = ", channel.channelId);
        console.log("             timeout  = ", channel.timeout);
        console.log("        remoteAddress = ", channel.remoteAddress);
        console.log("        remotePort    = ", channel.remotePort);
        console.log("");
        console.log("        bytesWritten  = ", channel.bytesWritten);
        console.log("        bytesRead     = ", channel.bytesRead);
github node-opcua / node-opcua / packages / node-opcua-server / source / server_end_point.ts View on Github external
} from "node-opcua-crypto";
import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";
import { getFullyQualifiedDomainName, resolveFullyQualifiedDomainName } from "node-opcua-hostname";
import {
    fromURI,
    MessageSecurityMode,
    SecurityPolicy,
    ServerSecureChannelLayer, ServerSecureChannelParent,
    toURI
} from "node-opcua-secure-channel";
import { UserTokenType } from "node-opcua-service-endpoints";
import { EndpointDescription } from "node-opcua-service-endpoints";
import { ApplicationDescription } from "node-opcua-service-endpoints";

const debugLog = make_debugLog(__filename);
const errorLog = make_errorLog(__filename);
const doDebug = checkDebugFlag(__filename);

const default_transportProfileUri = "http://opcfoundation.org/UA-Profile/Transport/uatcp-uasc-uabinary";

function dumpChannelInfo(channels: ServerSecureChannelLayer[]): void {

    function dumpChannel(channel: ServerSecureChannelLayer): void {

        console.log("------------------------------------------------------");
        console.log("            channelId = ", channel.channelId);
        console.log("             timeout  = ", channel.timeout);
        console.log("        remoteAddress = ", channel.remoteAddress);
        console.log("        remotePort    = ", channel.remotePort);
        console.log("");
        console.log("        bytesWritten  = ", channel.bytesWritten);
        console.log("        bytesRead     = ", channel.bytesRead);
github node-opcua / node-opcua / packages / node-opcua-file-transfer / source / client / client_file.ts View on Github external
/**
 * @module node-opcua-file-transfer-client
 */
import { Byte, Int32, UInt16, UInt32, UInt64 } from "node-opcua-basic-types";
import { AttributeIds } from "node-opcua-data-model";
import { NodeId } from "node-opcua-nodeid";
import { IBasicSession } from "node-opcua-pseudo-session";
import { ReadValueId, ReadValueIdOptions } from "node-opcua-service-read";
import { BrowsePath, makeBrowsePath } from "node-opcua-service-translate-browse-path";
import { StatusCodes } from "node-opcua-status-code";
import { DataType, VariantArrayType } from "node-opcua-variant";

import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";

const debugLog = make_debugLog("FileType");
const errorLog = make_errorLog("FileType");
const doDebug = checkDebugFlag("FileType");

import { OpenFileMode } from "../open_mode";

export { OpenFileMode } from "../open_mode";

export class ClientFile {

    public fileHandle: number = 0;

    private session: IBasicSession;
    private readonly fileNodeId: NodeId;

    private openMethodNodeId?: NodeId;
    private closeMethodNodeId?: NodeId;
    private setPositionNodeId?: NodeId;
github node-opcua / node-opcua / packages / node-opcua-transport / source / message_builder_base.ts View on Github external
/**
 * @module node-opcua-transport
 */
import { EventEmitter } from "events";
import { assert } from "node-opcua-assert";

import { BinaryStream } from "node-opcua-binary-stream";
import { createFastUninitializedBuffer } from "node-opcua-buffer-utils";
import { readMessageHeader, SequenceHeader } from "node-opcua-chunkmanager";
import { make_errorLog } from "node-opcua-debug";
import { PacketAssembler, PacketInfo } from "node-opcua-packet-assembler";
import { get_clock_tick } from "node-opcua-utils";

const doPerfMonitoring = process.env.NODEOPCUADEBUG && (process.env.NODEOPCUADEBUG.indexOf("PERF")) >= 0;

const errorLog = make_errorLog("MessageBuilder");

export function readRawMessageHeader(data: Buffer): PacketInfo {
    const messageHeader = readMessageHeader(new BinaryStream(data));
    return {
        extra: "",
        length: messageHeader.length,
        messageHeader
    };
}

/**
 * @class MessageBuilderBase
 * @extends EventEmitter
 * @uses PacketAssembler
 * @constructor
 * @param options {Object}
github node-opcua / node-opcua / packages / node-opcua-server-configuration / source / server / install_push_certitifate_management.ts View on Github external
import {
    ICertificateKeyPairProvider
} from "node-opcua-secure-channel";
import {
    OPCUAServer, OPCUAServerEndPoint
} from "node-opcua-server";
import {
    ApplicationDescriptionOptions
} from "node-opcua-types";
import {
    installPushCertificateManagement
} from "../push_certificate_manager_helpers";
import { ActionQueue } from "./push_certificate_manager_server_impl";

const debugLog = make_debugLog("ServerConfiguration");
const errorLog = make_errorLog("ServerConfiguration");
const doDebug = checkDebugFlag("ServerConfiguration");

export interface OPCUAServerPartial extends ICertificateKeyPairProvider {
    serverInfo?: ApplicationDescriptionOptions;
    serverCertificateManager: OPCUACertificateManager;
    $$privateKeyPEM: PrivateKeyPEM;
    $$certificate?: Certificate;
    $$certificateChain: Certificate;
}

function getCertificate(this: OPCUAServerPartial): Certificate {
    if (!this.$$certificate) {
        const certificateChain = getCertificateChain.call(this);
        this.$$certificate = split_der(certificateChain)[0];
    }
    return this.$$certificate!;
github node-opcua / node-opcua / packages / node-opcua-client / source / alarms_and_conditions / client_alarm_tools_acknowledge_all_conditions.ts View on Github external
import { CreateSubscriptionRequestOptions, MonitoringParametersOptions } from "node-opcua-service-subscription";
import { StatusCode, StatusCodes } from "node-opcua-status-code";
import {
    DataType,
    Variant
} from "node-opcua-variant";
import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";
import { ClientMonitoredItem } from "../client_monitored_item";
import { ClientSession } from "../client_session";
import { EventStuff, fieldsToJson } from "./client_alarm";
import { extractConditionFields } from "./client_alarm_tools_extractConditionFields";
import { callConditionRefresh } from "./client_tools";

const doDebug = checkDebugFlag(__filename);
const debugLog = make_debugLog(__filename);
const errorLog = make_errorLog(__filename);

/**
 *
 * @param session
 * @param eventStuff
 * @param comment
 */
export async function acknowledgeCondition(session: ClientSession, eventStuff: EventStuff, comment: string): Promise {

    try {
        const conditionId = eventStuff.conditionId.value;
        const eventId = eventStuff.eventId.value;
        return await session.acknowledgeCondition(conditionId, eventId, comment);
    } catch (err) {
        errorLog("Acknwoledding alarm has failed !", err);
        return StatusCodes.BadInternalError;
github node-opcua / node-opcua / packages / node-opcua-server-configuration / source / server / install_CertificateAlarm.ts View on Github external
import {
    AddressSpace,
    UACertificateExpirationAlarm
} from "node-opcua-address-space";
import {
    checkDebugFlag,
    make_debugLog,
    make_errorLog
} from "node-opcua-debug";
import {
    NodeId
} from "node-opcua-nodeid";

const debugLog = make_debugLog("ServerConfiguration");
const errorLog = make_errorLog("ServerConfiguration");
const doDebug = checkDebugFlag("ServerConfiguration");

export function installCertificateExpirationAlarm(addressSpace: AddressSpace) {

    debugLog("installCertificateExpirationAlarm");

    const server = addressSpace.rootFolder.objects.server;

    const namespace = addressSpace.getOwnNamespace();

    const certificateExpirationAlarmType = addressSpace.findEventType("CertificateExpirationAlarmType");

    const options = {
        browseName: "ServerCertificateAlarm",
        conditionSource: null,
        eventSourceOf: server,
github node-opcua / node-opcua / packages / node-opcua-file-transfer / source / server / file_type_helpers.ts View on Github external
UAFileType,
    UAMethod
} from "node-opcua-address-space";
import { Byte, Int32, UInt32, UInt64 } from "node-opcua-basic-types";
import { checkDebugFlag, make_debugLog, make_errorLog } from "node-opcua-debug";
import { CallMethodResultOptions } from "node-opcua-service-call";
import { StatusCodes } from "node-opcua-status-code";
import { DataType, Variant, VariantArrayType } from "node-opcua-variant";

import {
    OpenFileMode,
    OpenFileModeMask
} from "../open_mode";

const debugLog = make_debugLog("FileType");
const errorLog = make_errorLog("FileType");
const doDebug = checkDebugFlag("FileType");

/**
 *
 */
export interface FileOptions {
    /**
     * the filaname of the physical file which is managed by the OPCUA filetpye
     */
    filename: string;
    /**
     * the maximum allowed size of the  phisical file.
     */
    maxSize?: number;
    /**
     * an optional mimeType