로거 - 전역

  • 릴리스 버전: Washingtondc
  • 업데이트 날짜 2024년 02월 01일
  • 읽기4분
  • 로거 API는 이메일 로그에 메시지를 추가하는 인바운드 이메일 작업을 제공합니다.

    정보, 경고 및 오류 메시지를 추가하는 메서드를 제공합니다. 추가된 메시지의 원본은 email.<수신 이메일의 시스템 ID>로 설정됩니다.

    로거 - log(문자열 메시지)

    지정된 메시지를 이메일 로그에 추가합니다.

    표 1. 매개변수
    이름 유형 설명
    msg 문자열 이메일 로그에 추가할 텍스트입니다. 정보 유형 메시지여야 합니다.
    표 2. 반환
    유형 설명
    void

    이 코드 예제에서는 sys_user 테이블에서 전자 메일을 쿼리한 다음 보낸 사람 정보에 따라 적절한 로거 메서드를 호출합니다.

    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);
      }

    로거 - logError(문자열 메시지)

    지정된 오류 메시지를 이메일 로그 파일에 추가합니다.

    표 3. 매개변수
    이름 유형 설명
    msg 문자열 이메일 로그에 추가할 오류 메시지
    표 4. 반환
    유형 설명
    void

    이 코드 예제에서는 sys_user 테이블에서 전자 메일을 쿼리한 다음 보낸 사람 정보에 따라 적절한 로거 메서드를 호출합니다.

    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);
      }

    로거 - logWarning(문자열 메시지)

    지정된 경고 메시지를 전자 메일 로그 파일에 추가합니다.

    표 5. 매개변수
    이름 유형 설명
    msg 문자열 이메일 로그에 추가할 경고 메시지
    표 6. 반환
    유형 설명
    void

    이 코드 예제에서는 sys_user 테이블에서 전자 메일을 쿼리한 다음 보낸 사람 정보에 따라 적절한 로거 메서드를 호출합니다.

    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);
      }