Logger - グローバル

  • リリースバージョン: Washingtondc
  • 更新日 2024年02月01日
  • 読む4読むのに数分
  • Logger API は、メールログにメッセージを追加する受信メールアクションを提供します。

    情報、警告、およびエラーのメッセージを追加するメソッドを提供します。追加されるメッセージでは、送信元が email.<Sys ID of incoming email> に設定されます。

    Logger - log(文字列 msg)

    指定されたメッセージをメールログに追加します。

    表 : 1. パラメーター
    名前 タイプ 説明
    msg 文字列 メールログに追加するテキスト。情報タイプのメッセージである必要があります。
    表 : 2. 返される内容
    タイプ 説明
    なし

    このコード例では、sys_user テーブルからメールを照会し、送信者情報に基づいて適切な logger メソッドを呼び出します。

    var grUser = new GlideRecord("sys_user");
    grUser.addQuery("email", email.from);
    grUser.query();
      if (grUser.next()) {
        if (grUser.user_name) {
          logger.log("Sender found: " + email.from); //Append information message to the email log
          createInc(grUser.sys_id);
        } else {
            logger.logWarning("Sender: " + email.from + " " + "found but no userID found, please take necessary actions"); //Append warning message to the email log.
            createInc(grUser.sys_id);
        }
      } else {
          logger.logError("Sender is not present in the system hence action aborted"); //Append error message to the email log.
          current.setAbortAction(true);
      }

    Logger - logError(文字列 msg)

    指定されたエラーメッセージをメールログファイルに追加します。

    表 : 3. パラメーター
    名前 タイプ 説明
    msg 文字列 メールログに追加するエラーメッセージ
    表 : 4. 返される内容
    タイプ 説明
    なし

    このコード例では、sys_user テーブルからメールを照会し、送信者情報に基づいて適切な logger メソッドを呼び出します。

    var grUser = new GlideRecord("sys_user");
    grUser.addQuery("email", email.from);
    grUser.query();
      if (grUser.next()) {
        if (grUser.user_name) {
          logger.log("Sender found: " + email.from); //Append information message to the email log
          createInc(grUser.sys_id);
        } else {
            logger.logWarning("Sender: " + email.from + " " + "found but no userID found, please take necessary actions"); //Append warning message to the email log.
            createInc(grUser.sys_id);
        }
      } else {
          logger.logError("Sender is not present in the system hence action aborted"); //Append error message to the email log.
          current.setAbortAction(true);
      }

    Logger - logWarning(文字列 msg)

    指定された警告メッセージをメールログファイルに追加します。

    表 : 5. パラメーター
    名前 タイプ 説明
    msg 文字列 メールログに追加する警告メッセージ
    表 : 6. 返される内容
    タイプ 説明
    なし

    このコード例では、sys_user テーブルからメールを照会し、送信者情報に基づいて適切な logger メソッドを呼び出します。

    var grUser = new GlideRecord("sys_user");
    grUser.addQuery("email", email.from);
    grUser.query();
      if (grUser.next()) {
        if (grUser.user_name) {
          logger.log("Sender found: " + email.from); //Append information message to the email log
          createInc(grUser.sys_id);
        } else {
            logger.logWarning("Sender: " + email.from + " " + "found but no userID found, please take necessary actions"); //Append warning message to the email log.
            createInc(grUser.sys_id);
        }
      } else {
          logger.logError("Sender is not present in the system hence action aborted"); //Append error message to the email log.
          current.setAbortAction(true);
      }