WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Logging issue: Possible FormatException #10

@bahusoid

Description

@bahusoid

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions