Redth / HttpTwo

A basic C# HTTP/2 client library
Apache License 2.0
120 stars 51 forks source link

Logging issue: Possible FormatException #10

Open bahusoid opened 7 years ago

bahusoid commented 7 years ago

Current logging implementation is not safe:

         public void Error (string format, params object[] args)
        {
            if (Level >= LogLevel.Error)
                write (string.Format (format, args));
        }

        void write (string format, params object[] args)
        {
            Console.WriteLine (DateTime.Now.ToString ("hh:MM:ss.fff tt") + ": " + string.Format (format, args));
        }

You shouldn't use double string.Format calls. It will cause exception if first string.Format constructs string with "{" in it. For instance: Error("Some text: {0}", "Some arg with {0} placeholder ")

Also could you please disable by default logging for nuget package (at least I don't think that debug logging enabled by default is a good idea)