1 /* Copyright (C) 2012, 2018  Olga Yakovleva <yakovleva.o.v@gmail.com> */
2 
3 /* This program is free software: you can redistribute it and/or modify */
4 /* it under the terms of the GNU General Public License as published by */
5 /* the Free Software Foundation, either version 2 of the License, or */
6 /* (at your option) any later version. */
7 
8 /* This program is distributed in the hope that it will be useful, */
9 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
10 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the */
11 /* GNU General Public License for more details. */
12 
13 /* You should have received a copy of the GNU General Public License */
14 /* along with this program.  If not, see <http://www.gnu.org/licenses/>. */
15 
16 //#define _POSIX_C_SOURCE 1
17 #include <iostream>
18 #include <time.h>
19 #include <string.h>
20 #include "io.hpp"
21 
22 namespace RHVoice
23 {
24   namespace sd
25   {
message()26     message::message():
27       basic_message<message>(std::cout,false)
28     {
29     }
30 
message(bool throw_exceptions)31     message::message(bool throw_exceptions):
32       basic_message<message>(std::cout,throw_exceptions)
33     {
34     }
35 
getline()36     std::string getline()
37     {
38       std::string line;
39       if(std::getline(std::cin,line))
40         return line;
41       else
42         throw broken_pipe();
43     }
44 
45     numeric_property<unsigned int> logger::log_level("log_level",3,0,5);
46 
log_message()47     logger::log_message::log_message():
48       basic_message<log_message>(std::clog,false)
49     {
50     }
51 
start()52     void logger::log_message::start()
53     {
54       time_t t=time(0);
55       char s[32];
56       if(ctime_r(&t,s)==0)
57         return;
58       char* p=strchr(s,'\n');
59       if(p!=0)
60         *p=' ';
61       stream <<s << ' ';
62 }
63   }
64 }
65