basho/riak-dotnet-client

Eliminate use of Console for logging

Closed this issue · 6 comments

Options:

I do hope you'll consider my new found approach

class DebugInfo { public string message ="nothing"; } 

class Riak
{
    public Action<DebugInfo> Log = (info) =>  {}
     public void DoSomething() { Log(newDebugOptions); } 
}

Main 
{
    static void main() 
     { 
         var client = new Riak();
         client.Log += (info) => { Console.WriteLine(info.message); };
         client.DoSomething();
     }
}

I also don't know much about protocol buffers, but I know that you can interact with riak via rest or pbc, it'd be neat if also with logging if I got some debuginfo that had info that I could parse and generate a cURL request with for testing..

Like I mean given a Dictionary<string, string> I can do:

logitem.data.Where(w => w.GetType() == typeof(HttpRequest))
   .Cast<HttpRequest>()
    .ToList()
    .ForEach(f =>
    {
        Console.Write("curl -vvv -n -L '" + f.url + "'");
        f.headers.Keys
        .ToList()
        .ForEach(ff => Console.Write(" -H '" + ff + ": " + f.headers[ff] + "'"));
       Console.WriteLine();
});   

also with regards to my action/delegate suggestion:

"Controlling When and If a Delegate Fires Within a Multicast Delegate"
http://msdn.microsoft.com/en-us/library/orm-9780596516109-03-09.aspx

I wanna say you can probably write some code in your default Log handler to ensure that any multicast delegates outside of your own namespace are called asynchronously so that the logger doesn't end up blocking or something annoying. Basically trap the fire event, then re-fire each delegate subscriber in a thread pool or something. I donno that might be too much overhead, but people complain and I've never had any problems with reflection, it's always IO and blocking stuff that I have a problem with.

Sorry, I mentioned rabbitmq logging, it was actually websocketsharp's method of logging. I'm about to implement it according to the way they did theirs. I'll send you a pull request if you like it you can keep it if not, I'll maintain my own set of patches or something dumb I dont know I really need it to get through this though

spent some solid time puting together some stuff, I wanna show it off now but i think Im going to actually wait until I'm absolutely done for once. Sorry I got all frustrated and stuff today, I read too deep into things,

I just remember a time when I was pretty isolated and it was hard to find help and I had to either turn to things like support contracts ...I think made a huge mistake going with percona, considering I wanted xdb cluster, pretty difficult thing to setup and support. The learning curve is just steep with riak and theres a lot to know that I'm kicking myself for because I don't already know; I feel like I should I guess. Anyway starting to catch on and I tend to pick up things a lot better when I dive in head first like with hacking on CI, I think this is helping. Trusting your tools helps, it's easy to lose trust in something when its difficult to communicate the behavior you're seeing in a way that is comprehensible to others (ironically, that way being cURL is helping me a lot.)

At any rate, I'll have a pull request for you soon, crashing out though gnight