- All Implemented Interfaces:
Serializable,Comparable<Format>,Constable
数据格式枚举,定义支持的响应数据格式及其相关属性,并提供日志记录功能。
该枚举类用于标识响应数据的格式(如 XML、JSON、PDF、文件流),每个格式关联特定的数据提供者和媒体类型。 同时提供静态方法用于记录不同级别的日志(错误、警告、调试等)以及请求的开始和结束日志。
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionstatic void记录调试级别的日志。static void记录错误级别的日志。static void记录信息级别的日志。static voidrequestEnd(org.springframework.web.server.ServerWebExchange exchange, int statusCode) 记录请求结束的日志。static voidrequestStart(org.springframework.web.server.ServerWebExchange exchange) 记录请求开始的日志。static void记录跟踪级别的日志。static FormatReturns the enum constant of this class with the specified name.static Format[]values()Returns an array containing the constants of this enum class, in the order they are declared.static void记录警告级别的日志。
-
Enum Constant Details
-
XML
XML 格式,表示响应数据以 XML 格式输出。 -
JSON
JSON 格式,表示响应数据以 JSON 格式输出。 -
PDF
PDF 格式,表示响应数据以 PDF 格式输出。 -
BINARY
二进制文件流,表示响应数据以文件流形式输出。
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
error
public static void error(org.springframework.web.server.ServerWebExchange exchange, String operation, String message) 记录错误级别的日志。使用
Logger.error(String, Object...)记录错误日志,包含跟踪 ID、HTTP 方法、请求路径、操作描述和详细信息。- Parameters:
exchange-ServerWebExchange对象,包含请求和响应的上下文信息operation- 操作描述,用于标识日志的操作类型message- 详细的错误信息
-
warn
public static void warn(org.springframework.web.server.ServerWebExchange exchange, String operation, String message) 记录警告级别的日志。使用
Logger.warn(String, Object...)记录警告日志,包含跟踪 ID、HTTP 方法、请求路径、操作描述和详细信息。- Parameters:
exchange-ServerWebExchange对象,包含请求和响应的上下文信息operation- 操作描述,用于标识日志的操作类型message- 详细的警告信息
-
info
public static void info(org.springframework.web.server.ServerWebExchange exchange, String operation, String message) 记录信息级别的日志。使用
Logger.info(String, Object...)记录信息日志,包含跟踪 ID、HTTP 方法、请求路径、操作描述和详细信息。- Parameters:
exchange-ServerWebExchange对象,包含请求和响应的上下文信息operation- 操作描述,用于标识日志的操作类型message- 详细的信息
-
debug
public static void debug(org.springframework.web.server.ServerWebExchange exchange, String operation, String message) 记录调试级别的日志。使用
Logger.debug(String, Object...)记录调试日志,包含跟踪 ID、HTTP 方法、请求路径、操作描述和详细信息。- Parameters:
exchange-ServerWebExchange对象,包含请求和响应的上下文信息operation- 操作描述,用于标识日志的操作类型message- 详细的调试信息
-
trace
public static void trace(org.springframework.web.server.ServerWebExchange exchange, String operation, String message) 记录跟踪级别的日志。使用
Logger.trace(String, Object...)记录跟踪日志,包含跟踪 ID、HTTP 方法、请求路径、操作描述和详细信息。- Parameters:
exchange-ServerWebExchange对象,包含请求和响应的上下文信息operation- 操作描述,用于标识日志的操作类型message- 详细的跟踪信息
-
requestStart
public static void requestStart(org.springframework.web.server.ServerWebExchange exchange) 记录请求开始的日志。记录请求的开始信息,包括 HTTP 方法、请求路径和查询参数。 如果
exchange或上下文为null,则直接返回,不记录日志。- Parameters:
exchange-ServerWebExchange对象,包含请求和响应的上下文信息
-
requestEnd
public static void requestEnd(org.springframework.web.server.ServerWebExchange exchange, int statusCode) 记录请求结束的日志。记录请求的结束信息,包括 HTTP 方法、请求路径、响应状态码和执行时间。 如果
exchange或上下文为null,则直接返回,不记录日志。- Parameters:
exchange-ServerWebExchange对象,包含请求和响应的上下文信息statusCode- 响应状态码
-