You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2020/11/21 14:22:05 UTC

[thrift] branch master updated (966da29 -> 828ffa8)

This is an automated email from the ASF dual-hosted git repository.

jensg pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git.


    from 966da29  upgrade msys try get the soft
     new 1506661  Log errors in processor via standard logger #2284 Client: netstd Patch: Konstantin Pozdniakov & Jens Geyer
     new 828ffa8  silenced few warnings Client: netstd Patch: Jens Geyer

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../cpp/src/thrift/generate/t_netstd_generator.cc  | 16 +++++++++++++---
 test/netstd/Server/TestServer.cs                   | 22 ++++++++--------------
 2 files changed, 21 insertions(+), 17 deletions(-)


[thrift] 01/02: Log errors in processor via standard logger #2284 Client: netstd Patch: Konstantin Pozdniakov & Jens Geyer

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jensg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git

commit 1506661e92df5568c9e537bd68cd1c59dc55f38a
Author: Konstantin Pozdniakov <kpozdniakov>
AuthorDate: Sat Nov 21 10:13:29 2020 +0100

    Log errors in processor via standard logger #2284
    Client: netstd
    Patch: Konstantin Pozdniakov & Jens Geyer
    
    This closes #2284
---
 compiler/cpp/src/thrift/generate/t_netstd_generator.cc | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
index f1198e5..96963ee 100644
--- a/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_netstd_generator.cc
@@ -361,6 +361,7 @@ string t_netstd_generator::netstd_type_usings() const
         "using System.Linq;\n"
         "using System.Threading;\n"
         "using System.Threading.Tasks;\n"
+        "using Microsoft.Extensions.Logging;\n"
         "using Thrift;\n"
         "using Thrift.Collections;\n";
 
@@ -2134,8 +2135,9 @@ void t_netstd_generator::generate_service_server(ostream& out, t_service* tservi
     indent_up();
 
     out << indent() << "private readonly IAsync _iAsync;" << endl
+        << indent() << "private readonly ILogger<AsyncProcessor> _logger;" << endl
         << endl
-        << indent() << "public AsyncProcessor(IAsync iAsync)";
+        << indent() << "public AsyncProcessor(IAsync iAsync, ILogger<AsyncProcessor> logger = default)";
 
     if (!extends.empty())
     {
@@ -2147,6 +2149,7 @@ void t_netstd_generator::generate_service_server(ostream& out, t_service* tservi
     indent_up();
 
     out << indent() << "_iAsync = iAsync ?? throw new ArgumentNullException(nameof(iAsync));" << endl;
+    out << indent() << "_logger = logger;" << endl;
     for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter)
     {
         string function_name = (*f_iter)->get_name();
@@ -2380,8 +2383,15 @@ void t_netstd_generator::generate_process_function_async(ostream& out, t_service
         << indent() << "{" << endl;
     indent_up();
 
-    out << indent() << "Console.Error.WriteLine(\"Error occurred in processor:\");" << endl
-        << indent() << "Console.Error.WriteLine(ex.ToString());" << endl;
+    out << indent() << "var sErr = $\"Error occurred in {GetType().FullName}: {ex.Message}\";" << endl;
+    out << indent() << "if(_logger != null)" << endl;
+    indent_up();
+    out << indent() << "_logger.LogError(ex, sErr);" << endl;
+    indent_down();
+    out << indent() << "else" << endl;
+    indent_up();
+    out << indent() << "Console.WriteLine(sErr);" << endl;
+    indent_down();
 
     if (tfunction->is_oneway())
     {


[thrift] 02/02: silenced few warnings Client: netstd Patch: Jens Geyer

Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jensg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git

commit 828ffa8963efe14efd70e1c5c0688bab9f6714db
Author: Jens Geyer <je...@apache.org>
AuthorDate: Sat Nov 21 15:15:32 2020 +0100

    silenced few warnings
    Client: netstd
    Patch: Jens Geyer
---
 test/netstd/Server/TestServer.cs | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/test/netstd/Server/TestServer.cs b/test/netstd/Server/TestServer.cs
index 68461dc..5c99099 100644
--- a/test/netstd/Server/TestServer.cs
+++ b/test/netstd/Server/TestServer.cs
@@ -34,6 +34,8 @@ using Thrift.Server;
 using Thrift.Transport;
 using Thrift.Transport.Server;
 
+#pragma warning disable IDE0063  // using can be simplified, we don't
+
 namespace ThriftTest
 {
     internal enum ProtocolChoice
@@ -594,21 +596,13 @@ namespace ThriftTest
                             break;
                     }
 
-                    // Protocol (mandatory)
-                    TProtocolFactory proto;
-                    switch (param.protocol)
+                    TProtocolFactory proto = param.protocol switch
                     {
-                        case ProtocolChoice.Compact:
-                            proto = new TCompactProtocol.Factory();
-                            break;
-                        case ProtocolChoice.Json:
-                            proto = new TJsonProtocol.Factory();
-                            break;
-                        case ProtocolChoice.Binary:
-                        default:
-                            proto = new TBinaryProtocol.Factory();
-                            break;
-                    }
+                        ProtocolChoice.Compact => new TCompactProtocol.Factory(),
+                        ProtocolChoice.Json => new TJsonProtocol.Factory(),
+                        ProtocolChoice.Binary => new TBinaryProtocol.Factory(),
+                        _ => new TBinaryProtocol.Factory(),
+                    };
 
                     // Processor
                     var testHandler = new TestHandlerAsync();