AlbumenJ commented on code in PR #10292: URL: https://github.com/apache/dubbo/pull/10292#discussion_r917355912
########## dubbo-common/src/main/java/org/apache/dubbo/common/logger/ErrorType.java: ########## @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.logger; + +/** + * Represents an error type, which can be displayed by the logger like: + * ".... This may be caused by [error cause], go to [URL] to find instructions." + */ +public enum ErrorType { + + // Temporarily empty. The only one entry is for testing. + REGISTRY_CENTER_OFFLINE("registry center offline", "http://dubbo.apache.org/"); Review Comment: 具体报错的信息不要带有官网地址,把官网地址抽成一个静态变量 ########## dubbo-common/src/main/java/org/apache/dubbo/common/logger/ErrorType.java: ########## @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.logger; + +/** + * Represents an error type, which can be displayed by the logger like: + * ".... This may be caused by [error cause], go to [URL] to find instructions." + */ +public enum ErrorType { + + // Temporarily empty. The only one entry is for testing. + REGISTRY_CENTER_OFFLINE("registry center offline", "http://dubbo.apache.org/"); + + /** + * Error cause. + */ + private final String cause; + + /** + * Link to instructions. + */ + private final String errorUrl; Review Comment: 这里需要有错误码,类似 1-1,1-2 这种(第一位是报错类型,第二位是报错序号) 报错类型是类似“注册中心”、“路由” 这种 ########## dubbo-common/src/main/java/org/apache/dubbo/common/logger/ErrorType.java: ########## @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.logger; + +/** + * Represents an error type, which can be displayed by the logger like: + * ".... This may be caused by [error cause], go to [URL] to find instructions." + */ +public enum ErrorType { + + // Temporarily empty. The only one entry is for testing. + REGISTRY_CENTER_OFFLINE("registry center offline", "http://dubbo.apache.org/"); + + /** + * Error cause. + */ + private final String cause; + + /** + * Link to instructions. + */ + private final String errorUrl; Review Comment: FAQ链接基于报错码自动生成 ########## dubbo-common/src/main/java/org/apache/dubbo/common/logger/support/FailsafeErrorTypeAwareLogger.java: ########## @@ -0,0 +1,160 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.logger.support; + +import org.apache.dubbo.common.Version; +import org.apache.dubbo.common.logger.ErrorType; +import org.apache.dubbo.common.logger.ErrorTypeAwareLogger; +import org.apache.dubbo.common.logger.Logger; +import org.apache.dubbo.common.utils.NetUtils; + +/** + * A fail-safe (ignoring exception thrown by logger) wrapper of error type aware logger. + */ +public class FailsafeErrorTypeAwareLogger extends FailsafeLogger implements ErrorTypeAwareLogger { + + public FailsafeErrorTypeAwareLogger(Logger logger) { + super(logger); + } + + private String appendContextMessageWithInstructions(ErrorType errorType, String msg) { + return " [DUBBO] " + msg + ", dubbo version: " + Version.getVersion() + Review Comment: 报错码这里需要输出 ########## dubbo-common/src/main/java/org/apache/dubbo/common/logger/ErrorType.java: ########## @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.dubbo.common.logger; + +/** + * Represents an error type, which can be displayed by the logger like: + * ".... This may be caused by [error cause], go to [URL] to find instructions." + */ +public enum ErrorType { + + // Temporarily empty. The only one entry is for testing. + REGISTRY_CENTER_OFFLINE("registry center offline", "http://dubbo.apache.org/"); + + /** + * Error cause. + */ + private final String cause; + + /** + * Link to instructions. + */ + private final String errorUrl; Review Comment: 需要扩展一个字端在报错的时候可以自定义透出一些信息 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
