/usr/include/buteosyncfw5/Logger.h is in libbuteosyncfw5-dev 0.7.21+16.04.20151216.1-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | /*
* This file is part of buteo-syncfw package
*
* Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Contact: Sateesh Kavuri <sateesh.kavuri@nokia.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public License
* version 2.1 as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA
*
*/
#ifndef LOGGER_H
#define LOGGER_H
#include <QBitArray>
#include <QDebug>
#include <QFile>
#include <QList>
#include <QMutex>
#include <QString>
#include <QTextStream>
namespace Buteo {
/*!
* \brief A logger singleton class.
*
* Using the logger is thread safe, but creating the instance is not.
* Make sure that the instance is created before any threads that use the
* logger are started. This can be done by calling createInstance explicitly,
* or by simply logging some message, which will automatically create the
* logger instance with default parameters.
*/
class Q_DECL_EXPORT Logger
{
public:
static const int NUM_LEVELS = 4;
//! Default indent size.
static const int DEFAULT_INDENT_SIZE;
/*!
* \brief Returns the logger instance.
*
* If the instance is not yet created, creates it with default parameters.
* @return The instance.
*/
static Logger *instance();
//! Destructor.
~Logger();
/*!
* \brief Creates a logger instance.
*
* If an instance already exists, deletes the old instance first.
* This function should be called in the beginning of the program
* before any threads using the logger are created, because creating
* the log instance is not thread safe.
* @param aLogFileName Name of the file where log messages are written.
* If this is empty, messages are not written to a file.
* @param aUseStdOut Should messages be written to standard output.
* @param aIndentSize Number of spaces that each indent level inserts.
*/
static void createInstance(const QString &aLogFileName = "",
bool aUseStdOut = false,
int aIndentSize = DEFAULT_INDENT_SIZE);
//! Deletes the logger instance. Closes the log file in a controlled way.
static void deleteInstance();
/*!
* \brief Enables given log levels.
* @param aLevels Log levels to enable. Default enables all levels.
*/
void enable(const QBitArray &aLevels = QBitArray(NUM_LEVELS, true));
/*!
* \brief Disables given log levels.
* @param aLevels Log levels to disable. Default disables all levels.
*/
void disable(const QBitArray &aLevels = QBitArray(NUM_LEVELS, true));
/*!
* \brief Adds one indent level.
*/
void push();
/*!
* \brief Removes one indent level.
*/
void pop();
/*!
* \brief Writes a message to the log.
*
* @param aLevel Message level.
* @param aMsg Message.
*/
void write(int aLevel, const char *aMsg);
/*!
* \brief Sets logging level.
*
* Messages with the given level and levels more severe than it will be
* enabled. Qt built-in log levels will also be enabled.
* @param aLevel Logging level.
*/
bool setLogLevel(int aLevel);
/*!
* \brief Gets logging level BitArray
*
* Use this API to count the levels the BitArray has been set to true
*/
QBitArray getLogLevelArray();
/*!
* \brief Gets the logging level as a single number.
*/
int getLogLevel() const;
bool enabled(){return iEnabled;}
private:
Logger(const QString &aLogFileName, bool aUseStdOut, int aIndentSize);
static int defaultLogLevel();
static Logger *sInstance;
QBitArray iEnabledLevels;
int iIndentLevel;
int iIndentSize;
QFile iFile;
QTextStream *iFileStream;
QTextStream *iStdOutStream;
QTextStream *iStdErrStream;
QMutex iMutex;
bool iEnabled;
int iLogLevel;
};
}
#endif // LOGGER_H
|