how good is my debugging "library"

closed account (Dy7SLyTq)
so i wrote the debugging part of my library and i was just wondering any improvements i could make to it?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include   <string>
#include  <cstdlib>

using std::  cout;
using std::  cerr;
using std::  endl;
using std::string;
using std::  exit;

namespace Debug
{
    bool Log(int Line, string File)
    {
        static int Current = 1;

        cout<< File <<": Log ("<< Current++ <<") @ Line: "<< Line << endl;

        return true;
    }

    void Error(int Line, string Message, bool Fatal = false)
    {
        if(!Fatal) CacheError("error on line " + string(Line) + ": " + Error);

        else
        {
            CacheError("fatal error on line " + string(Line) + ": " + Error);

            cerr<< CacheError(true);
            exit(-1);
        }
    }

    string CacheError(string Message = "", bool Flush = false)
    {
        static string Log = "";

        if(Flush) return Log;

        else Log += Message + "\n";
    }
}


with the exception of Log::Log (which i will call when i need to do some minor testing and dont feel like powering on the debugger) Error and as a result CacheError will only get called when an exception is caught

edit: i had the wrong namespace name
Last edited on
There is a difference between logging and debugging. You shouldn't have to write code to enable debugging, your debugger should do that for you.
closed account (Dy7SLyTq)
im not using an ide and i dont like gdb so i would have to use the debugger i have. i use the logger to find the bugs and then fix them
Have you seen StackWalker on CodeProject? Really awesome. I use it at work to find the sources of exceptions (because of various reasons, I can't simply break on all exceptions when they're thrown, so the debugger is no help on this).
closed account (Dy7SLyTq)
ill look at it. is it only windows (because i know code Projects is very windows heavy)
AFAIK, yes.
closed account (Dy7SLyTq)
i could be wrong but i was looking at the source for the class and saw a bunch of windows.h data types
What did you think helios meant by "yes"?
Which is why I said that as far as I know it's only for Windows.
closed account (Dy7SLyTq)
i incorrectly remembered what i asked him. for some reason i thought i asked if it was cross platform
Topic archived. No new replies allowed.