GCC Code Coverage Report


Directory: ./
File: src/log.cc
Date: 2024-08-14 11:04:57
Exec Total Coverage
Lines: 0 10 0.0%
Branches: 0 10 0.0%

Line Branch Exec Source
1 // Copyright (c) 2020, Joseph Mirabel
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4 // This file is part of gepetto-viewer.
5 // gepetto-viewer is free software: you can redistribute it
6 // and/or modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation, either version
8 // 3 of the License, or (at your option) any later version.
9 //
10 // gepetto-viewer is distributed in the hope that it will be
11 // useful, but WITHOUT ANY WARRANTY; without even the implied warranty
12 // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Lesser Public License for more details. You should have
14 // received a copy of the GNU Lesser General Public License along with
15 // gepetto-viewer. If not, see <http://www.gnu.org/licenses/>.
16
17 #include "log.hh"
18
19 #include <fstream>
20 #include <iostream>
21
22 namespace gepetto {
23
24 QStringInsertFunction& insertFunction() {
25 // Default function to use to insert a QString.
26 static QStringInsertFunction insertFunction(use_toLocal8Bit);
27 return insertFunction;
28 }
29
30 std::ofstream& logfile() GEPETTO_VIEWER_LOCAL;
31
32 std::ofstream& logfile() {
33 static std::ofstream ofs;
34 return ofs;
35 }
36
37 void setLogFile(const char* filename) { logfile().open(filename); }
38
39 std::ostream& log() {
40 if (logfile().good())
41 return logfile();
42 else
43 return std::cout;
44 }
45 } // namespace gepetto
46