summaryrefslogtreecommitdiff
path: root/library/error_log.h
blob: ff4d3aee7205c77241f2b93432c78d923210b9f8 (plain)
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
44
45
46
47
48
49
50
51
// **************************************************************************
// * This file is part of the FreeFileSync project. It is distributed under *
// * GNU General Public License: http://www.gnu.org/licenses/gpl.html       *
// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de)                    *
// **************************************************************************
//
#ifndef ERRORLOGGING_H_INCLUDED
#define ERRORLOGGING_H_INCLUDED

#include <wx/string.h>
#include <vector>
#include <map>
#include "../shared/zstring.h"


namespace ffs3
{
enum MessageType
{
    TYPE_INFO        = 1,
    TYPE_WARNING     = 2,
    TYPE_ERROR       = 4,
    TYPE_FATAL_ERROR = 8,
};

class ErrorLogging
{
public:
    void logMsg(const wxString& message, MessageType type);

    int typeCount(int types = TYPE_INFO | TYPE_WARNING | TYPE_ERROR | TYPE_FATAL_ERROR) const;

    std::vector<wxString> getFormattedMessages(int types = TYPE_INFO | TYPE_WARNING | TYPE_ERROR | TYPE_FATAL_ERROR) const;

private:
    struct Entry
    {
        MessageType type;
        time_t      time;
        wxString    message;
    };

    static wxString formatMessage(const Entry& msg);

    std::vector<Entry> messages; //list of non-resolved errors and warnings

    mutable std::map<MessageType, int> statistics;
};
}

#endif // ERRORLOGGING_H_INCLUDED
bgstack15