Line data Source code
1 : // tinygettext - A gettext replacement that works directly on .po files
2 : // Copyright (c) 2009 Ingo Ruhnke <grumbel@gmail.com>
3 : //
4 : // This software is provided 'as-is', without any express or implied
5 : // warranty. In no event will the authors be held liable for any damages
6 : // arising from the use of this software.
7 : //
8 : // Permission is granted to anyone to use this software for any purpose,
9 : // including commercial applications, and to alter it and redistribute it
10 : // freely, subject to the following restrictions:
11 : //
12 : // 1. The origin of this software must not be misrepresented; you must not
13 : // claim that you wrote the original software. If you use this software
14 : // in a product, an acknowledgement in the product documentation would be
15 : // appreciated but is not required.
16 : // 2. Altered source versions must be plainly marked as such, and must not be
17 : // misrepresented as being the original software.
18 : // 3. This notice may not be removed or altered from any source distribution.
19 :
20 : #include "precompiled.h"
21 :
22 : #include <iostream>
23 : #include "tinygettext/log.hpp"
24 :
25 : namespace tinygettext {
26 :
27 : Log::log_callback_t Log::log_info_callback = &Log::default_log_callback;
28 : Log::log_callback_t Log::log_warning_callback = &Log::default_log_callback;
29 : Log::log_callback_t Log::log_error_callback = &Log::default_log_callback;
30 :
31 : void
32 0 : Log::default_log_callback(const std::string& str)
33 : {
34 0 : std::cerr << "tinygettext: " << str;
35 0 : }
36 :
37 : void
38 0 : Log::set_log_info_callback(log_callback_t callback)
39 : {
40 0 : log_info_callback = callback;
41 0 : }
42 :
43 : void
44 0 : Log::set_log_warning_callback(log_callback_t callback)
45 : {
46 0 : log_warning_callback = callback;
47 0 : }
48 :
49 : void
50 0 : Log::set_log_error_callback(log_callback_t callback)
51 : {
52 0 : log_error_callback = callback;
53 0 : }
54 :
55 0 : Log::Log(log_callback_t callback_) :
56 : callback(callback_),
57 0 : out()
58 : {
59 0 : }
60 :
61 0 : Log::~Log()
62 : {
63 0 : callback(out.str());
64 0 : }
65 :
66 : std::ostream&
67 0 : Log::get()
68 : {
69 0 : return out;
70 : }
71 :
72 3 : } // namespace tinygettext
73 :
74 : /* EOF */
|