Blammo.Net's class documentation is included in the download. The usage documentation is below:

Configuration

Blammo.Net uses Gestalt.Net for configuration. As such most aspects are simple to configure and any changes can be done in either code or in the XML config file (if you choose to have one). Once you reference Blammo.Net all you need to do to configure it is add a class that inherits from BlammoNet.Config.Config. It can look as simple as this:
    public class LoggingConfig : BlammoNet.Config.Config
    {
        public override string LogFileLocation { get { return HttpContext.Current.Server.MapPath("~/App_Data/Logs/"); } }
    }


The class above, when loaded by the system, will simply tell Blammo.Net to put all logs in our App_Data/Logs directory. In fact, if you wanted you could leave out the LogFileLocation property and it would simply put them into C:\Logs\. Any of the properties of BlammoNet.Config.Config can be overridden from the defaults. If you would prefer to make your changes to an XML file instead of recompiling, all you need to do is override the ConfigFileLocation property and set where you would like the config file to be located (it is automatically generated the first time the app is run). You can also set defaults in this case by setting values in the constructor:

    public class LoggingConfig : BlammoNet.Config.Config
    {
        public LoggingConfig()
            : base()
        {
            LogFileLocation = HttpContext.Current.Server.MapPath("~/App_Data/Logs/");
        }

        protected override string ConfigFileLocation { get { return HttpContext.Current.Server.MapPath("~/App_Data/Logging.config"); } }
    }


For specific information on each property, please see the class documentation enclosed with download.

Setup

Setup is rather simple and requires two calls:
            Gestalt.Manager.Instance.RegisterConfigFile(typeof(LoggingConfig).Assembly);
            BlammoNet.Manager Temp = BlammoNet.Manager.Instance;


The first is used to set up Gestalt.Net. A call to RegisterConfigFile, sending in the assembly containing your config class, is all that is needed for the config class to be registered and usable. The Blammo.Net setup occurs automatically the first time you try to use it. Both Gestalt.Net and Blammo.Net are singletons. In the case of Blammo.Net, as soon as you try to use it for anything, it initializes itself. So instead of an assignment, you could simply start with:

            BlammoNet.Manager.Instance.GetLog().LogMessage("This is my message", BlammoNet.Enum.MessageType.Info);


And it would initialize the manager and then log your message. Note that Blammo.Net's manager is IDisposable, so you may wish to save a static instance of it to dispose of it when you are finished.

Logging

Once you've set everything up, you have only a couple of functions to deal with for usage. The first is actually getting a log from the manager:

            BlammoNet.Manager.Instance.GetLog()


The GetLog function gets the log that you specify, or creates it if need be (it has a default value of "Default", so the code above would end up getting the Default log). Once you have the log, you can actually save a message using this:

            BlammoNet.Manager.Instance.GetLog().LogMessage("This is my message", BlammoNet.Enum.MessageType.Info);


The LogMessage function takes the message text and message type (using an enum). It can also take in arguments, which it can use to format the message string. For example we can do the following:

            BlammoNet.Manager.Instance.GetLog().LogMessage("This is my {0}", BlammoNet.Enum.MessageType.Info,"message");


That would end up giving us the same message as the earlier example. Anyway, that's all there is to using the system.

Last edited May 19, 2010 at 6:51 PM by JaCraig, version 1

Comments

No comments yet.