How to use the @bentley/bentleyjs-core.Logger.logTrace function in @bentley/bentleyjs-core

To help you get started, we’ve selected a few @bentley/bentleyjs-core 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 imodeljs / imodeljs / test-apps / agent-test-app / src / QueryAgent.ts View on Github external
private async _extractChangeSummary(changeSetId: string) {
        const accessToken: AccessToken = await this._tokenStore!.getAccessToken();
        if (!this._iModelDb) {
            // Open a new local briefcase of the iModel at the specified version
            this._iModelDb = await IModelDb.open(actx, accessToken, this._projectId!, this._iModelId!, OpenParams.pullOnly(AccessMode.Exclusive), IModelVersion.asOfChangeSet(changeSetId));
        } else {
            // Update the existing local briefcase of the iModel to the specified version
            await this._iModelDb.pullAndMergeChanges(actx, accessToken, IModelVersion.asOfChangeSet(changeSetId));
        }

        // Extract summary information about the current version of the briefcase/iModel into the change cache
        const changeSummaryIds: Id64String[] = await ChangeSummaryManager.extractChangeSummaries(actx, accessToken, this._iModelDb!, { currentVersionOnly: true });
        Logger.logTrace(QueryAgentConfig.loggingCategory, `Extracted summary information from change set "${changeSetId}"`);

        // Attach a change cache file to the iModel to enable querying the change summary
        ChangeSummaryManager.attachChangeCache(this._iModelDb);

        // Find the change summary that was just created
        assert(changeSummaryIds.length === 1);
        const changeSummary: ChangeSummary = ChangeSummaryManager.queryChangeSummary(this._iModelDb!, changeSummaryIds[0]);

        /*
        * Query the change summary to gather up all the content
        */
        const changeContent = { id: changeSummary.id, changeSet: changeSummary.changeSet, instanceChanges: {} };

        Logger.logTrace(QueryAgentConfig.loggingCategory, `   Description: ${changeSummary.changeSet.description}`);
        Logger.logTrace(QueryAgentConfig.loggingCategory, `   Push Date: ${new Date(changeSummary.changeSet.pushDate).toLocaleString()}`);
        Logger.logTrace(QueryAgentConfig.loggingCategory, `   User Created: ${changeSummary.changeSet.userCreated}`);
github imodeljs / imodeljs / core / backend / src / ChangeSummaryManager.ts View on Github external
startChangeSetId = await options.startVersion.evaluateChangeSet(requestContext, ctx.iModelId, BriefcaseManager.imodelClient);
        requestContext.enter();
      } else if (options.currentVersionOnly) {
        startChangeSetId = endChangeSetId;
      }
    }

    Logger.logInfo(loggerCategory, "Started Change Summary extraction...", () => ({ iModelId: ctx.iModelId, startChangeSetId, endChangeSetId }));
    const totalPerf = new PerfLogger(`ChangeSummaryManager.extractChangeSummaries [Changesets: ${startChangeSetId} through ${endChangeSetId}, iModel: ${ctx.iModelId}]`);

    // download necessary changesets if they were not downloaded before and retrieve infos about those changesets
    let perfLogger = new PerfLogger("ChangeSummaryManager.extractChangeSummaries>Retrieve ChangeSetInfos and download ChangeSets from Hub");
    const changeSetInfos: ChangeSet[] = await ChangeSummaryManager.downloadChangeSets(requestContext, ctx, startChangeSetId, endChangeSetId);
    requestContext.enter();
    perfLogger.dispose();
    Logger.logTrace(loggerCategory, "Retrieved changesets to extract from from cache or from hub.", () => ({ iModelId: ctx.iModelId, startChangeSetId, endChangeSetId, changeSets: changeSetInfos }));

    // Detach change cache as it's being written to during the extraction
    const isChangeCacheAttached = this.isChangeCacheAttached(iModel);
    if (isChangeCacheAttached)
      ChangeSummaryManager.detachChangeCache(iModel);

    perfLogger = new PerfLogger("ChangeSummaryManager.extractChangeSummaries>Open or create local Change Cache file");
    const changesFile: ECDb = ChangeSummaryManager.openOrCreateChangesFile(iModel);
    perfLogger.dispose();
    Logger.logTrace(loggerCategory, "Opened or created Changes Cachefile.", () => ({ iModelId: ctx.iModelId, startChangeSetId, endChangeSetId }));

    if (!changesFile || !changesFile.nativeDb) {
      assert(false, "Should not happen as an exception should have been thrown in that case");
      throw new IModelError(IModelStatus.BadArg, "Failed to create Change Cache file.");
    }
github imodeljs / imodeljs / ui / framework / src / ui-framework / toolbar / Toolbar.tsx View on Github external
if (itemDimensions > (this._dimension - padding)) {
        const overflowItems: AnyItemDef[] = [];
        const lastItemIndex = actionItems.length - 1;
        let singleItemSize = 0;
        for (let index = lastItemIndex; index >= 0; index--) {
          if (actionItems[index] instanceof CustomItemDef)
            continue;
          if (0 === singleItemSize)
            singleItemSize = actionItems[index].getDimension(this.props.orientation);

          const deletedItems = actionItems.splice(index, 1);
          // istanbul ignore else
          if (deletedItems.length === 1) {
            const item = deletedItems[0];
            overflowItems.unshift(item);
            Logger.logTrace(UiFramework.loggerCategory(this), `  * Item [${item.id ? item.id : item.label}] put into overflow items.`);

            let currentWidth = 0;
            actionItems.forEach((itemDef) => currentWidth += (itemDef.getDimension(this.props.orientation) + 1));
            itemDimensions = (currentWidth + singleItemSize);
            if (itemDimensions < (this._dimension - padding))
              break;
          }
        }

        overflowItemDef = new GroupItemDef({
          groupId: `overflow-group-${itemDimensions}-${actionItems.length}-${overflowItems.length}`,
          labelKey: "UiFramework:general.overflow",
          items: overflowItems,
          direction: this.props.expandsTo,
        });
        overflowItemDef.overflow = true;
github imodeljs / imodeljs / core / backend / src / IModelExporter.ts View on Github external
if (this._sourceDbChanges.codeSpecs.insertedIds.has(codeSpec.id)) {
        isUpdate = false;
      } else if (this._sourceDbChanges.codeSpecs.updatedIds.has(codeSpec.id)) {
        isUpdate = true;
      } else {
        return; // not in changeSet, don't export
      }
    }
    // passed changeSet test, now apply standard exclusion rules
    if (this._excludedCodeSpecNames.has(codeSpec.name)) {
      Logger.logInfo(loggerCategory, `Excluding CodeSpec: ${codeSpec.name}`);
      return;
    }
    // CodeSpec has passed standard exclusion rules, now give handler a chance to accept/reject export
    if (this.handler.callProtected.shouldExportCodeSpec(codeSpec)) {
      Logger.logTrace(loggerCategory, `exportCodeSpec(${codeSpecName})` + isUpdate ? " UPDATE" : "");
      this.handler.callProtected.onExportCodeSpec(codeSpec, isUpdate);
    }
  }
github imodeljs / imodeljs / core / clients / src / imodelhub / GlobalEvents.ts View on Github external
public async delete(requestContext: AuthorizedClientRequestContext, subscriptionId: string): Promise {
    requestContext.enter();
    Logger.logInfo(loggerCategory, "Deleting global event subscription", () => ({ subscriptionId }));
    ArgumentCheck.defined("requestContext", requestContext);
    ArgumentCheck.validGuid("subscriptionInstanceId", subscriptionId);

    await this._handler.delete(requestContext, this.getRelativeUrl(subscriptionId));
    requestContext.enter();
    Logger.logTrace(loggerCategory, "Deleted global event subscription", () => ({ subscriptionId }));
  }
}
github imodeljs / imodeljs / core / clients / src / Request.ts View on Github external
const logResponse = (req: sarequest.SuperAgentRequest, startTime: number) => (res: sarequest.Response) => {
  const elapsed = new Date().getTime() - startTime;
  const elapsedTime = elapsed + "ms";
  Logger.logTrace(loggerCategory, `${req.method.toUpperCase()} ${res.status} ${req.url} (${elapsedTime})`);
};
github imodeljs / imodeljs / core / clients / src / imodelhub / Briefcases.ts View on Github external
public async download(requestContext: AuthorizedClientRequestContext, briefcase: Briefcase, path: string, progressCallback?: (progress: ProgressInfo) => void): Promise {
    requestContext.enter();
    Logger.logTrace(loggerCategory, "Started downloading briefcase", () => ({ ...briefcase, path }));
    ArgumentCheck.defined("briefcase", briefcase);
    ArgumentCheck.defined("path", path);

    if (typeof window !== "undefined")
      return Promise.reject(IModelHubClientError.browser());

    if (!this._fileHandler)
      return Promise.reject(IModelHubClientError.fileHandler());

    if (!briefcase.downloadUrl)
      return Promise.reject(IModelHubClientError.missingDownloadUrl("briefcase"));

    await this._fileHandler.downloadFile(requestContext, briefcase.downloadUrl, path, parseInt(briefcase.fileSize!, 10), progressCallback);
    requestContext.enter();
    Logger.logTrace(loggerCategory, "Finished downloading briefcase", () => ({ ...briefcase, path }));
  }
github imodeljs / imodeljs / core / clients / src / imodelhub / iModels.ts View on Github external
private async waitForInitializion(requestContext: AuthorizedClientRequestContext, contextId: string, imodel: HubIModel, timeOutInMilliseconds: number): Promise {
    requestContext.enter();
    const errorMessage = "iModel initialization failed";
    const retryDelay = timeOutInMilliseconds / 10;
    for (let retries = 10; retries > 0; --retries) {
      try {
        const initState = await this.getInitializationState(requestContext, imodel.id!);
        requestContext.enter();
        if (initState === InitializationState.Successful) {
          Logger.logTrace(loggerCategory, "Created iModel", () => ({ contextId, iModelId: imodel.id }));
          imodel.initialized = true;
          return imodel;
        }

        if (initState !== InitializationState.NotStarted && initState !== InitializationState.Scheduled) {
          Logger.logWarning(loggerCategory, errorMessage);
          return Promise.reject(new IModelHubError(IModelHubStatus.SeedFileInitializationFailed,
            `Seed file initialization failed with status ${InitializationState[initState]}`));
        }

        await new Promise((resolve) => setTimeout(resolve, retryDelay));
        requestContext.enter();
      } catch (err) {
        requestContext.enter();
        Logger.logWarning(loggerCategory, errorMessage);
        return Promise.reject(err);
github imodeljs / imodeljs / core / clients-backend / src / oidc / OidcDeviceClient.ts View on Github external
private async makeRevokeTokenRequest(requestContext: ClientRequestContext): Promise {
    requestContext.enter();
    if (!this._configuration)
      throw new BentleyError(AuthStatus.Error, "Not initialized. First call initialize()", Logger.logError, loggerCategory);
    if (!this._tokenResponse)
      throw new BentleyError(AuthStatus.Error, "Missing refresh token. First call signIn() and ensure it's successful", Logger.logError, loggerCategory);

    const request = new RevokeTokenRequest({ token: this._tokenResponse.refreshToken! });
    await this._tokenHandler.performRevokeTokenRequest(this._configuration, request);
    requestContext.enter();

    this._tokenResponse = undefined;
    Logger.logTrace(loggerCategory, "Authorization revoked, and removed access token");
    this.onUserStateChanged.raiseEvent(undefined);
  }
}
github imodeljs / imodeljs / core / clients / src / imodelhub / Locks.ts View on Github external
} else {
      locks = await this._handler.postQuery(requestContext, Lock, this.getRelativeUrl(iModelId, false), query.getQueryOptions());
      requestContext.enter();
      locks = locks.map((value: Lock) => {
        const result = new Lock();
        result.briefcaseId = value.briefcaseId;
        result.lockLevel = value.lockLevel;
        result.lockType = value.lockType;
        result.objectId = value.objectId;
        if (value.seedFileId)
          result.seedFileId = value.seedFileId;
        return result;
      });
    }

    Logger.logTrace(loggerCategory, `Queried ${locks.length} locks for iModel`, () => ({ iModelId }));
    return locks;
  }