Help Writing a Logger Program

Discussion in 'C#' started by SeanXD, Oct 18, 2009.

  1. SeanXD

    SeanXD New Member

    Oct 18, 2009
    Likes Received:
    Trophy Points:
    Our teacher for my 3D Game Programming class has given us a project to create a Logger Class using an Interface to log certain attributes of at least 3 objects in a game we create and to write that information to one text file and output it onto the game screen. He has not given us any information on how to do it and has basically old us to figure it out on our own. It is probably simple, but he has given certain restrictions on how to write it. He does not what he has written to be changed (with the exception of the semi colons at the end of the headers). He has given a basic outline of the logger class and interface with the function headers, but I do not know what to write in them. I do understand that I must use Singleton structures in this program, but I am truly stumped on how to implement it. I am very inexperienced in programming and I really need some help on what to do with this assignment. Here is the text he gave us listing exactly what he wants done and if anyone can send me some sort of rough solution to it, it would be greatly appreciated.

    "Implement the following Interface and Class. Comments must be followed. You cannot alter method
    signatures. You may add in whatever additional public/protected/private methods or properties you
    feel is needed to implement. Also show a simple example of at least 3 objects reporting info to the
    logger, both on screen and to a file. The sample does not need to be in 3D.

    Run clean build on the sample, zip it up, and turn it in here.

        //returns the text the object wants to report
        public string Report();
        //Private constructor to enfource Singleton access
        private Logger();
        //Draws the current log information to the screen using SpriteBatch.DrawString
        //Need to be called every frame
        public void Draw();    
        //takes an object that implements ILog and stores it for later use
        public bool RegisterObject(ILog obj);
        //remove the object from the registration data structure
        public bool UnregisterObject(ILog obj);
        //removes all objects from the registration data structure
        public void UnregisterAll();
        //Starts file logging.  Must not crash or corrupt the file if called twice in a row.
        //file name must be in the format of: gamename-hh-mm-ss-dd-mm-yyyy.txt
        //pattern is hours-minutes-seconds-day-month-year for clarification
        public void StartFileLogging();
        //ends file logging.  Must not crash if called before StartFileLogging()
        public void EndFileLogging();
        //starts displaying the log info to screen
        public void StartScreenDisplay();
        //stops displaying log info to screen
        public void StopScreenDisplay();
        //Updates the report data if nessacary.  Update is called every frame, but should
        //only update information every UpdateInterval
        public void Update(GameTime gameTime);
        //internal method that actually gathers all the info
        protected void GatherInfo();
        //performs the actualy act of writing to the log file
        protected void WriteFile();
        //all intervals are in milliseconds
        //interval for writing to file
        public int FileWriteInterval{get; set;};
        //interval for updating log data
        public int UpdateInterval{get; set;};
        //defines where to start drawing log info on screen
        public Vector2 DrawLocation;
        //returns an instance of Logger
        public static Logger GetInstance{get;};    
    Last edited by a moderator: Oct 18, 2009

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice