001/* 002 * Copyright © 2025 CUI-OpenSource-Software (info@cuioss.de) 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package de.cuioss.http.client; 017 018import de.cuioss.tools.logging.LogRecord; 019import de.cuioss.tools.logging.LogRecordModel; 020import lombok.experimental.UtilityClass; 021 022/** 023 * Provides logging messages for the de.cuioss.tools.net.http package. 024 * All messages follow the format: HTTP-[identifier]: [message] 025 * <p> 026 * This separate LogMessages class is specific to the HTTP utilities package 027 * and complements the main JWTValidationLogMessages for the module. 028 * 029 * @since 1.0 030 */ 031@UtilityClass 032public final class HttpLogMessages { 033 034 private static final String PREFIX = "HTTP"; 035 036 /** 037 * Contains informational log messages for successful operations or status updates. 038 */ 039 @UtilityClass 040 public static final class INFO { 041 042 public static final LogRecord RETRY_OPERATION_SUCCEEDED_AFTER_ATTEMPTS = LogRecordModel.builder() 043 .prefix(PREFIX) 044 .identifier(10) 045 .template("Operation '%s' succeeded on attempt %s/%s") 046 .build(); 047 } 048 049 /** 050 * Contains warning-level log messages for potential issues that don't prevent 051 * normal operation but may indicate problems. 052 */ 053 @UtilityClass 054 public static final class WARN { 055 056 public static final LogRecord CONTENT_CONVERSION_FAILED = LogRecordModel.builder() 057 .prefix(PREFIX) 058 .identifier(100) 059 .template("Content conversion failed for response from %s") 060 .build(); 061 062 public static final LogRecord HTTP_STATUS_WARNING = LogRecordModel.builder() 063 .prefix(PREFIX) 064 .identifier(101) 065 .template("HTTP %s (%s) from %s") 066 .build(); 067 068 public static final LogRecord HTTP_FETCH_FAILED = LogRecordModel.builder() 069 .prefix(PREFIX) 070 .identifier(102) 071 .template("Failed to fetch HTTP content from %s") 072 .build(); 073 074 public static final LogRecord HTTP_FETCH_INTERRUPTED = LogRecordModel.builder() 075 .prefix(PREFIX) 076 .identifier(103) 077 .template("Interrupted while fetching HTTP content from %s") 078 .build(); 079 080 public static final LogRecord RETRY_MAX_ATTEMPTS_REACHED = LogRecordModel.builder() 081 .prefix(PREFIX) 082 .identifier(104) 083 .template("Operation '%s' failed after %s attempts. Final exception: %s") 084 .build(); 085 086 public static final LogRecord RETRY_OPERATION_FAILED = LogRecordModel.builder() 087 .prefix(PREFIX) 088 .identifier(105) 089 .template("Retry operation '%s' failed after %s attempts in %sms") 090 .build(); 091 092 public static final LogRecord HTTP_PING_IO_ERROR = LogRecordModel.builder() 093 .prefix(PREFIX) 094 .identifier(106) 095 .template("IO error while pinging URI %s: %s") 096 .build(); 097 098 public static final LogRecord HTTP_PING_INTERRUPTED = LogRecordModel.builder() 099 .prefix(PREFIX) 100 .identifier(107) 101 .template("Interrupted while pinging URI %s: %s") 102 .build(); 103 104 public static final LogRecord HTTP_PING_ERROR = LogRecordModel.builder() 105 .prefix(PREFIX) 106 .identifier(108) 107 .template("Error while pinging URI %s: %s") 108 .build(); 109 110 public static final LogRecord SSL_INSECURE_PROTOCOL = LogRecordModel.builder() 111 .prefix(PREFIX) 112 .identifier(109) 113 .template("Provided SSL context uses insecure protocol: %s. Creating a secure context instead.") 114 .build(); 115 } 116 117 /** 118 * Contains debug-level log messages for detailed information during development and troubleshooting. 119 */ 120 @UtilityClass 121 public static final class DEBUG { 122 123 public static final LogRecord SSL_CONTEXT_PROTOCOL = LogRecordModel.builder() 124 .prefix(PREFIX) 125 .identifier(200) 126 .template("Provided SSL context uses protocol: %s") 127 .build(); 128 129 public static final LogRecord SSL_USING_PROVIDED_CONTEXT = LogRecordModel.builder() 130 .prefix(PREFIX) 131 .identifier(201) 132 .template("Using provided SSL context with protocol: %s") 133 .build(); 134 135 public static final LogRecord SSL_CREATED_SECURE_CONTEXT = LogRecordModel.builder() 136 .prefix(PREFIX) 137 .identifier(202) 138 .template("Created secure SSL context with %s") 139 .build(); 140 141 public static final LogRecord SSL_NO_CONTEXT_PROVIDED = LogRecordModel.builder() 142 .prefix(PREFIX) 143 .identifier(203) 144 .template("No SSL context provided, created secure SSL context with %s") 145 .build(); 146 147 public static final LogRecord HTTP_NOT_MODIFIED = LogRecordModel.builder() 148 .prefix(PREFIX) 149 .identifier(204) 150 .template("Received 304 Not Modified from %s") 151 .build(); 152 153 public static final LogRecord HTTP_RESPONSE_RECEIVED = LogRecordModel.builder() 154 .prefix(PREFIX) 155 .identifier(205) 156 .template("Received %s %s from %s with ETag: %s") 157 .build(); 158 159 public static final LogRecord RETRY_ATTEMPT_STARTING = LogRecordModel.builder() 160 .prefix(PREFIX) 161 .identifier(206) 162 .template("Starting retry attempt %s for operation '%s'") 163 .build(); 164 165 public static final LogRecord RETRY_NON_RETRYABLE_ERROR = LogRecordModel.builder() 166 .prefix(PREFIX) 167 .identifier(207) 168 .template("Operation failed with non-retryable error for '%s' after %sms") 169 .build(); 170 171 public static final LogRecord RETRY_ATTEMPT_FAILED = LogRecordModel.builder() 172 .prefix(PREFIX) 173 .identifier(208) 174 .template("Retry attempt %s failed for operation '%s' after %sms - retryable error") 175 .build(); 176 177 public static final LogRecord RETRY_DELAY_INTERRUPTED = LogRecordModel.builder() 178 .prefix(PREFIX) 179 .identifier(209) 180 .template("Retry delay interrupted for '%s', returning last operation result") 181 .build(); 182 183 public static final LogRecord RETRY_DELAY_DEVIATION = LogRecordModel.builder() 184 .prefix(PREFIX) 185 .identifier(210) 186 .template("Retry delay deviation for '%s': planned=%sms, actual=%sms, difference=%sms") 187 .build(); 188 } 189 190}