Subversion Repositories HomeAutomation

Rev

Rev 1311 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1311 Rev 1314
Line 20... Line 20...
20
}
20
}
21
 
21
 
22
void Logger::setName(string className)
22
void Logger::setName(string className)
23
{
23
{
24
    this->myClassName = className;
24
    this->myClassName = className;
-
 
25
}
-
 
26
 
-
 
27
string Logger::getFormatedTime()
-
 
28
{
-
 
29
    struct tm tmStruct;
-
 
30
    time_t t = time(NULL);
-
 
31
    localtime_r(&t, &tmStruct);
-
 
32
 
-
 
33
    string hours = convert::int2string(tmStruct.tm_hour);
-
 
34
    string minutes = convert::int2string(tmStruct.tm_min);
-
 
35
    string seconds = convert::int2string(tmStruct.tm_sec);
-
 
36
 
-
 
37
    string_::pad_left(hours, 2, '0');
-
 
38
    string_::pad_left(minutes, 2, '0');
-
 
39
    string_::pad_left(seconds, 2, '0');
-
 
40
 
-
 
41
    return hours + ":" + minutes + ":" + seconds;
25
}
42
}
26
 
43
 
27
void Logger::info(string message)
44
void Logger::info(string message)
28
{
45
{
29
    cout << niceTime() << " INFO  " << rpad(this->myClassName, 20, ' ') << message << endl;
46
    cout << Logger::getFormatedTime() << " INFO  " << string_::pad_right_copy(this->myClassName, 20, ' ') << message << endl;
30
}
47
}
31
 
48
 
32
void Logger::debug(string message)
49
void Logger::debug(string message)
33
{
50
{
34
    cout << niceTime() << " DEBUG " << rpad(this->myClassName, 20, ' ') << message << endl;
51
    cout << Logger::getFormatedTime() << " DEBUG " << string_::pad_right_copy(this->myClassName, 20, ' ') << message << endl;
35
}
52
}
36
 
53
 
37
void Logger::warn(string message)
54
void Logger::warn(string message)
38
{
55
{
39
    cout << niceTime() << " WARN  " << rpad(this->myClassName, 20, ' ') << message << endl;
56
    cout << Logger::getFormatedTime() << " WARN  " << string_::pad_right_copy(this->myClassName, 20, ' ') << message << endl;
40
}
57
}
41
 
58
 
42
void Logger::error(string message)
59
void Logger::error(string message)
43
{
60
{
44
    cout << niceTime() << " ERROR " << rpad(this->myClassName, 20, ' ') << message << endl;
61
    cout << Logger::getFormatedTime() << " ERROR " << string_::pad_right_copy(this->myClassName, 20, ' ') << message << endl;
45
}
62
}
46
 
63
 
47
void Logger::fatal(string message)
64
void Logger::fatal(string message)
48
{
65
{
49
    cout << niceTime() << " FATAL " << rpad(this->myClassName, 20, ' ') << message << endl;
66
    cout << Logger::getFormatedTime() << " FATAL " << string_::pad_right_copy(this->myClassName, 20, ' ') << message << endl;
50
}
67
}
51
 
68
 
52
 
69
 
53
}
70
}
54
}
71
}