How to use the @bentley/bentleyjs-core.Logger.logWarning 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 / plugins / geo-photo / src / ProjectSharePhotoTree.ts View on Github external
public async updateTags(requestContext: AuthorizedClientRequestContext, contextId: GuidString, psFile: PSPhotoFile): Promise {
    try {
      const tags = await psFile.readTagsFromJpeg();
      if (tags === undefined) {
        Logger.logWarning(loggerCategory, "Jpeg does not have any geographic location", () => ({ ...psFile.psFile }));
        return undefined;
      }
      await this.saveTags(requestContext, contextId, psFile, tags);
      return tags;
    } catch (error) {
      // tslint:disable-next-line:no-console
      console.log(`Error ${error} attempting to read tags of ${psFile.name}`);
      return undefined;
    }
  }
github imodeljs / imodeljs / plugins / geo-photo / src / JpegTagReader.ts View on Github external
case 6:
          // console.log('Thumbnail image format is JPEG');
          if (thumbTags.has("JpegIFOffset") && thumbTags.has("JpegIFByteCount")) {
            // extract the thumbnail
            const tOffset = tiffStart + (thumbTags.get("JpegIFOffset") as number);
            const tLength = thumbTags.get("JpegIFByteCount") as number;

            if (tOffset + tLength > dataView.byteLength)
              Logger.logWarning(loggerCategory, "Cannot extract thumbnail blob");
            else
              thumbTags.set("blob", Buffer.from(dataView.buffer, tOffset, tLength));
          }
          break;

        case 1:
          Logger.logWarning(loggerCategory, "Thumbnail image format is TIFF, which is not implemented.");
          break;
        default:
          Logger.logWarning(loggerCategory, "Unknown thumbnail image format", () => ({ format: thumbTags.get("Compression") }));
      }
    } else if (thumbTags.get("PhotometricInterpretation") === 2) {
      Logger.logWarning(loggerCategory, "Thumbnail image format is RGB, which is not implemented.");
    }
    return thumbTags;
  }
github imodeljs / imodeljs / plugins / geo-photo / src / JpegTagReader.ts View on Github external
// Data format is ordinary JPEG format, starts from 0xFFD8 and ends by 0xFFD9. It seems that
    // JPEG format and 160x120pixels of size are recommended thumbnail format for Exif2.1 or later.

    if (thumbTags.has("Compression")) {
      // console.log('Thumbnail image found!');

      switch (thumbTags.get("Compression") as number) {
        case 6:
          // console.log('Thumbnail image format is JPEG');
          if (thumbTags.has("JpegIFOffset") && thumbTags.has("JpegIFByteCount")) {
            // extract the thumbnail
            const tOffset = tiffStart + (thumbTags.get("JpegIFOffset") as number);
            const tLength = thumbTags.get("JpegIFByteCount") as number;

            if (tOffset + tLength > dataView.byteLength)
              Logger.logWarning(loggerCategory, "Cannot extract thumbnail blob");
            else
              thumbTags.set("blob", Buffer.from(dataView.buffer, tOffset, tLength));
          }
          break;

        case 1:
          Logger.logWarning(loggerCategory, "Thumbnail image format is TIFF, which is not implemented.");
          break;
        default:
          Logger.logWarning(loggerCategory, "Unknown thumbnail image format", () => ({ format: thumbTags.get("Compression") }));
      }
    } else if (thumbTags.get("PhotometricInterpretation") === 2) {
      Logger.logWarning(loggerCategory, "Thumbnail image format is RGB, which is not implemented.");
    }
    return thumbTags;
  }
github imodeljs / imodeljs / core / backend / src / IModelDb.ts View on Github external
}

      if (undefined !== ret.error) {
        reject(new IModelError(ret.error.status, "TreeId=" + treeId + " TileId=" + tileId));
      } else if (typeof ret.result !== "number") { // if type is not a number, it's the TileContent interface
        const res = ret.result as IModelJsNative.TileContent;
        let iModelId = this._iModel.iModelToken.iModelId;
        if (undefined === iModelId) {
          // iModel not in hub - therefore we're almost certainly not logging to SEQ so don't much care...
          iModelId = "";
        }

        const tileSizeThreshold = IModelHost.logTileSizeThreshold;
        const tileSize = res.content.length;
        if (tileSize > tileSizeThreshold) {
          Logger.logWarning(loggerCategory, "Tile size (in bytes) larger than specified threshold", () => ({ tileSize, tileSizeThreshold, treeId, tileId, iModelId }));
        }

        const loadTimeThreshold = IModelHost.logTileLoadTimeThreshold;
        const loadTime = res.elapsedSeconds;
        if (loadTime > loadTimeThreshold) {
          Logger.logWarning(loggerCategory, "Tile load time (in seconds) greater than specified threshold", () => ({ loadTime, loadTimeThreshold, treeId, tileId, iModelId }));
        }

        resolve(res.content);
      } else { // if the type is a number, it's the TileContentState enum
        // ###TODO: Decide appropriate timeout interval. May want to switch on state (new vs loading vs pending)
        setTimeout(() => this.pollTileContent(resolve, reject, treeId, tileId, requestContext), 10);
      }
    }
github imodeljs / imodeljs / core / backend / src / BriefcaseManager.ts View on Github external
if (DbResult.BE_SQLITE_OK !== res)
      throw new IModelError(res, `Cannot open briefcase at ${pathname}`, Logger.logError, loggerCategory, () => ({ iModelId, pathname, openParams }));

    const briefcase = new BriefcaseEntry(contextId, iModelId, changeSetId, pathname, openParams, briefcaseId);
    briefcase.setNativeDb(nativeDb); // Note: Sets briefcaseId, currentChangeSetId in BriefcaseEntry by reading the values from nativeDb
    assert(briefcase.isOpen);

    // Validate the briefcase
    let isValidBriefcase: boolean = true;
    if (briefcase.currentChangeSetId !== briefcase.targetChangeSetId) {
      if (openParams.syncMode === SyncMode.FixedVersion) {
        Logger.logError(loggerCategory, "Briefcase found is invalid (is not of required version). Deleting it to allow retries", () => briefcase.getDebugInfo());
        isValidBriefcase = false;
      } else {
        if (nativeDb.hasUnsavedChanges() || nativeDb.hasSavedChanges())
          Logger.logWarning(loggerCategory, "Briefcase found with local changes, but is not of required version. Ignoring required version", () => briefcase.getDebugInfo());
        else
          isValidBriefcase = false; // Invalidate the briefcase to refetch it
      }
    }
    if (briefcase.briefcaseId !== briefcaseId) {
      Logger.logError(loggerCategory, "Briefcase found is invalid (does not have the expected briefcase id). Deleting it to allow retries", () => ({ expectedBriefcaseId: briefcaseId, ...briefcase.getDebugInfo() }));
      isValidBriefcase = false;
    }
    if (!isValidBriefcase) {
      BriefcaseManager.closeBriefcase(briefcase, false);
      BriefcaseManager.deleteBriefcaseFromLocalDisk(briefcase);
      return undefined;
    }

    const cachedBriefcase = this._cache.findBriefcase(briefcase);
    if (cachedBriefcase) {
github imodeljs / imodeljs / plugins / geo-photo / src / JpegTagReader.ts View on Github external
// extract the thumbnail
            const tOffset = tiffStart + (thumbTags.get("JpegIFOffset") as number);
            const tLength = thumbTags.get("JpegIFByteCount") as number;

            if (tOffset + tLength > dataView.byteLength)
              Logger.logWarning(loggerCategory, "Cannot extract thumbnail blob");
            else
              thumbTags.set("blob", Buffer.from(dataView.buffer, tOffset, tLength));
          }
          break;

        case 1:
          Logger.logWarning(loggerCategory, "Thumbnail image format is TIFF, which is not implemented.");
          break;
        default:
          Logger.logWarning(loggerCategory, "Unknown thumbnail image format", () => ({ format: thumbTags.get("Compression") }));
      }
    } else if (thumbTags.get("PhotometricInterpretation") === 2) {
      Logger.logWarning(loggerCategory, "Thumbnail image format is RGB, which is not implemented.");
    }
    return thumbTags;
  }
github imodeljs / imodeljs / plugins / geo-photo / src / JpegTagReader.ts View on Github external
if (tOffset + tLength > dataView.byteLength)
              Logger.logWarning(loggerCategory, "Cannot extract thumbnail blob");
            else
              thumbTags.set("blob", Buffer.from(dataView.buffer, tOffset, tLength));
          }
          break;

        case 1:
          Logger.logWarning(loggerCategory, "Thumbnail image format is TIFF, which is not implemented.");
          break;
        default:
          Logger.logWarning(loggerCategory, "Unknown thumbnail image format", () => ({ format: thumbTags.get("Compression") }));
      }
    } else if (thumbTags.get("PhotometricInterpretation") === 2) {
      Logger.logWarning(loggerCategory, "Thumbnail image format is RGB, which is not implemented.");
    }
    return thumbTags;
  }
github imodeljs / imodeljs / core / clients / src / ulas / LogEntryConverter.ts View on Github external
private static getSessionId(requestContext: AuthorizedClientRequestContext): GuidString {
    if (!Guid.isGuid(requestContext.sessionId)) {
      Logger.logWarning(loggerCategory, "Specified sessionId is not a valid Guid. Set up IModelApp.sessionId for frontend applications, or IModelHost.sessionId for agents");
      return Guid.empty;
    }

    return requestContext.sessionId;
  }
github imodeljs / imodeljs / core / common / src / rpc / core / RpcInvocation.ts View on Github external
if (!parameters || !Array.isArray(parameters)) {
      return;
    }

    for (let i = 0; i !== parameters.length; ++i) {
      const parameter = parameters[i];
      const isToken = typeof (parameter) === "object" && parameter !== null && parameter.hasOwnProperty("iModelId") && parameter.hasOwnProperty("contextId");
      if (isToken && this.protocol.checkToken && !this.operation.policy.allowTokenMismatch) {
        const inflated = this.protocol.inflateToken(parameter, this.request);
        parameters[i] = inflated;

        if (!RpcInvocation.compareTokens(parameter, inflated)) {
          if (RpcConfiguration.throwOnTokenMismatch) {
            throw new IModelError(BentleyStatus.ERROR, "IModelToken mismatch detected for this request.");
          } else {
            Logger.logWarning(CommonLoggerCategory.RpcInterfaceBackend, "IModelToken mismatch detected for this request.");
          }
        }
      }
    }
  }