1 /*
2  * This file is part of Licq, an instant messaging client for UNIX.
3  * Copyright (C) 2010 Licq Developers <licq-dev@googlegroups.com>
4  *
5  * Please refer to the COPYRIGHT file distributed with this source
6  * distribution for the names of the individual contributors.
7  *
8  * Licq is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * Licq is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with Licq; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21  */
22 
23 #ifndef LICQ_LOGUTILS_H
24 #define LICQ_LOGUTILS_H
25 
26 #include "log.h"
27 #include "logsink.h"
28 
29 #include <string>
30 
31 namespace Licq
32 {
33 
34 namespace LogUtils
35 {
36 
37 bool levelInBitmask(Log::Level level, unsigned int bitmask);
38 bool packetInBitmask(unsigned int bitmask);
39 
40 /**
41  * Converts a bitmask in the old format to a new that can be passed to
42  * AdjustableLogSink::setLogLevelsFromBitmask().
43  * @param levels A bitmask indicating which levels to log:
44  *   0x01 - Log::Info
45  *   0x02 - Log::Unknown
46  *   0x04 - Log::Error
47  *   0x08 - Log::Warning
48  *   0x10 - Log::Debug and packets
49  */
50 unsigned int convertOldBitmaskToNew(int levels);
51 
52 const char* levelToString(Log::Level level);
53 const char* levelToShortString(Log::Level level);
54 std::string timeToString(const LogSink::Message::Time& msgTime);
55 
56 /**
57  * Pretty-print a packet to a string
58  *
59  * @param message Message with the packet to print
60  * @return A printable string containing the packet data
61  */
62 std::string packetToString(LogSink::Message::Ptr message);
63 
64 } // namespace LogUtils
65 
66 } // namespace Licq
67 
68 #endif
69