source: BAORadio/libindi/libindi/BAOcontrol/LogFile.cpp @ 689

Last change on this file since 689 was 689, checked in by frichard, 12 years ago
File size: 1.6 KB
Line 
1/*
2 * Author and Copyright of this file and of the stellarium telescope feature:
3 * Johannes Gajdosik, 2006
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18 */
19
20#include "LogFile.hpp"
21
22#include <iostream>
23#include <iomanip>
24
25ostream *log_file = &cout;
26
27static ofstream log_stream;
28
29void SetLogFile(const char *name) {
30  if (log_file == &log_stream) {
31    log_stream.close();
32  }
33  if (name && name[0]) {
34    log_file = &log_stream;
35    log_stream.open(name,ios::out|ios::trunc);
36  } else {
37    log_file = &cout;
38  }
39}
40
41ostream &operator<<(ostream &o,const Now &now) {
42  long long int x = now.time;
43  const int micros = x % 1000000; x /= 1000000;
44  const int secs = x % 60; x /= 60;
45  const int mins = x % 60; x /= 60;
46  const int hours = x % 24; x /= 24;
47  o << x
48    << ',' << setw(2) << setfill('0') << hours
49    << ':' << setw(2) << setfill('0') << mins
50    << ':' << setw(2) << setfill('0') << secs
51    << '.' << setw(6) << setfill('0') << micros
52    << setfill(' ') << ": ";
53  return o;
54}
Note: See TracBrowser for help on using the repository browser.