File: log.h

package info (click to toggle)
libwx-perl 1%3A0.9932-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,300 kB
  • sloc: cpp: 11,064; perl: 8,603; ansic: 711; makefile: 53
file content (131 lines) | stat: -rw-r--r-- 4,630 bytes parent folder | download | duplicates (5)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/////////////////////////////////////////////////////////////////////////////
// Name:        cpp/log.h
// Purpose:     c++ wrapper for wxLog and wxLogPassThrough
// Author:      Mattia Barbon
// Modified by:
// Created:     22/09/2002
// RCS-ID:      $Id: log.h 3402 2012-10-01 11:18:15Z mdootson $
// Copyright:   (c) 2002-2004 Mattia Barbon
// Licence:     This program is free software; you can redistribute it and/or
//              modify it under the same terms as Perl itself
/////////////////////////////////////////////////////////////////////////////

#include <wx/log.h>

class wxPlLog : public wxLog
{
//    WXPLI_DECLARE_DYNAMIC_CLASS( wxPlLog );
    WXPLI_DECLARE_V_CBACK();
public:
    WXPLI_DEFAULT_CONSTRUCTOR_NC( wxPlLog, "Wx::PlLog", true );
#if WXPERL_W_VERSION_LT( 2, 9, 0 ) || WXWIN_COMPATIBILITY_2_8
    DEC_V_CBACK_VOID__CWXCHARP_TIMET( DoLogString );
    DEC_V_CBACK_VOID__WXLOGLEVEL_CWXCHARP_TIMET( DoLog );
#endif
    DEC_V_CBACK_VOID__VOID( Flush );
#if WXPERL_W_VERSION_GE( 2, 9, 0 )
    DEC_V_CBACK_VOID__WXLOGLEVEL_WXSTRING_WXLOGRECORDINFO( DoLogRecord );
    DEC_V_CBACK_VOID__WXLOGLEVEL_WXSTRING( DoLogTextAtLevel );
    DEC_V_CBACK_VOID__WXSTRING( DoLogText );
#endif
};
#if WXPERL_W_VERSION_LT( 2, 9, 0 ) || WXWIN_COMPATIBILITY_2_8
DEF_V_CBACK_VOID__CWXCHARP_TIMET( wxPlLog, wxLog, DoLogString );
DEF_V_CBACK_VOID__WXLOGLEVEL_CWXCHARP_TIMET( wxPlLog, wxLog, DoLog );
#endif

DEF_V_CBACK_VOID__VOID( wxPlLog, wxLog, Flush );

#if WXPERL_W_VERSION_GE( 2, 9, 0 )
DEF_V_CBACK_VOID__WXLOGLEVEL_WXSTRING_WXLOGRECORDINFO( wxPlLog, wxLog, DoLogRecord );
DEF_V_CBACK_VOID__WXLOGLEVEL_WXSTRING( wxPlLog, wxLog, DoLogTextAtLevel );
DEF_V_CBACK_VOID__WXSTRING( wxPlLog, wxLog, DoLogText );
#endif

class wxPlLogPassThrough : public wxLogPassThrough
{
//    WXPLI_DECLARE_DYNAMIC_CLASS( wxPlLogPassThrough );
    WXPLI_DECLARE_V_CBACK();
public:
    WXPLI_DEFAULT_CONSTRUCTOR_NC( wxPlLogPassThrough,
                                  "Wx::PlLogPassThrough", true );
#if WXPERL_W_VERSION_LT( 2, 9, 0 ) || WXWIN_COMPATIBILITY_2_8
    DEC_V_CBACK_VOID__CWXCHARP_TIMET( DoLogString );
    DEC_V_CBACK_VOID__WXLOGLEVEL_CWXCHARP_TIMET( DoLog );
#endif
#if WXPERL_W_VERSION_GE( 2, 9, 0 )
    DEC_V_CBACK_VOID__WXLOGLEVEL_WXSTRING_WXLOGRECORDINFO( DoLogRecord );
    DEC_V_CBACK_VOID__WXLOGLEVEL_WXSTRING( DoLogTextAtLevel );
    DEC_V_CBACK_VOID__WXSTRING( DoLogText );
#endif
};

#if WXPERL_W_VERSION_LT( 2, 9, 0 ) || WXWIN_COMPATIBILITY_2_8
DEF_V_CBACK_VOID__CWXCHARP_TIMET( wxPlLogPassThrough, wxLogPassThrough,
                                  DoLogString );
DEF_V_CBACK_VOID__WXLOGLEVEL_CWXCHARP_TIMET( wxPlLogPassThrough,
                                             wxLogPassThrough, DoLog );
#endif
#if WXPERL_W_VERSION_GE( 2, 9, 0 )
DEF_V_CBACK_VOID__WXLOGLEVEL_WXSTRING_WXLOGRECORDINFO( wxPlLogPassThrough, wxLogPassThrough, DoLogRecord );
DEF_V_CBACK_VOID__WXLOGLEVEL_WXSTRING( wxPlLogPassThrough, wxLogPassThrough, DoLogTextAtLevel );
DEF_V_CBACK_VOID__WXSTRING( wxPlLogPassThrough, wxLogPassThrough, DoLogText );
#endif

#if WXPERL_W_VERSION_GE( 2, 9, 0 )
class wxPlLogFormatter : public wxLogFormatter
{
    WXPLI_DECLARE_V_CBACK();
public:
    WXPLI_DEFAULT_CONSTRUCTOR_NC( wxPlLogFormatter,
                                  "Wx::PlLogFormatter", true );
    
    wxString Format(wxLogLevel level,
                            const wxString& msg,
                            const wxLogRecordInfo& info) const;
protected:
    
    wxString FormatTime(time_t t) const;
};

wxString
wxPlLogFormatter::Format(wxLogLevel level,
                            const wxString& msg,
                            const wxLogRecordInfo& info) const
{
    dTHX;
    if( wxPliFCback( aTHX_ &m_callback, "Format" ) ) 
    {                                                               
        wxAutoSV ret( aTHX_ wxPliCCback( aTHX_ &m_callback, G_SCALAR,
                              "IPq", level, &msg, &info, "Wx::LogRecordInfo" ) );
        wxString val;
        WXSTRING_INPUT( val, wxString, ret );
        return val;
    }
    else
        return wxLogFormatter::Format( level, msg, info );

}

wxString
wxPlLogFormatter::FormatTime(time_t t) const
{
    dTHX;
    if( wxPliFCback( aTHX_ &m_callback, "FormatTime" ) ) 
    {                                                               
        wxAutoSV ret( aTHX_ wxPliCCback( aTHX_ &m_callback, G_SCALAR,
                              "i", t) );
        wxString val;
        WXSTRING_INPUT( val, wxString, ret );
        return val;
    }
    else
        return wxLogFormatter::FormatTime( t );

}

#endif

// local variables:
// mode: c++
// end: