mirror of
https://github.com/benapetr/stikkit.git
synced 2025-04-26 13:01:08 -05:00
first code
This commit is contained in:
parent
d2a146244c
commit
7698599f13
3
stikkit/configuration.cpp
Normal file
3
stikkit/configuration.cpp
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#include "configuration.hpp"
|
||||||
|
|
||||||
|
unsigned int Configuration::Verbosity = 0;
|
12
stikkit/configuration.hpp
Normal file
12
stikkit/configuration.hpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef CONFIGURATION_HPP
|
||||||
|
#define CONFIGURATION_HPP
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
|
class Configuration
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static unsigned int Verbosity;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // CONFIGURATION_HPP
|
12
stikkit/main.cpp
Normal file
12
stikkit/main.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include <QCoreApplication>
|
||||||
|
#include "configuration.hpp"
|
||||||
|
#include "syslog.hpp"
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
//QCoreApplication a(argc, argv);
|
||||||
|
|
||||||
|
//return a.exec();
|
||||||
|
Stikkit::Syslog::Log("hi");
|
||||||
|
return 0;
|
||||||
|
}
|
28
stikkit/stikkit.pro
Normal file
28
stikkit/stikkit.pro
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#-------------------------------------------------
|
||||||
|
#
|
||||||
|
# Project created by QtCreator 2014-05-24T19:01:03
|
||||||
|
#
|
||||||
|
#-------------------------------------------------
|
||||||
|
|
||||||
|
QT += core
|
||||||
|
|
||||||
|
QT -= gui
|
||||||
|
|
||||||
|
TARGET = stikkit
|
||||||
|
CONFIG += console
|
||||||
|
CONFIG -= app_bundle
|
||||||
|
|
||||||
|
TEMPLATE = app
|
||||||
|
|
||||||
|
|
||||||
|
SOURCES += main.cpp \
|
||||||
|
syslog.cpp \
|
||||||
|
webquery.cpp \
|
||||||
|
configuration.cpp \
|
||||||
|
terminalparser.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
syslog.hpp \
|
||||||
|
webquery.hpp \
|
||||||
|
configuration.hpp \
|
||||||
|
terminalparser.hpp
|
47
stikkit/syslog.cpp
Normal file
47
stikkit/syslog.cpp
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
//This program is free software: you can redistribute it and/or modify
|
||||||
|
//it under the terms of the GNU General Public License as published by
|
||||||
|
//the Free Software Foundation, either version 3 of the License, or
|
||||||
|
//(at your option) any later version.
|
||||||
|
|
||||||
|
//This program 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 General Public License for more details.
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <QDateTime>
|
||||||
|
#include "syslog.hpp"
|
||||||
|
#include "configuration.hpp"
|
||||||
|
|
||||||
|
using namespace Stikkit;
|
||||||
|
|
||||||
|
void Syslog::Log(QString Message, StikkitLogType Type)
|
||||||
|
{
|
||||||
|
QString d = QDateTime::currentDateTime().toString();
|
||||||
|
QString message = d + " " + Message;
|
||||||
|
if (Type == StikkitLogType_Error)
|
||||||
|
{
|
||||||
|
std::cerr << message.toStdString() << std::endl;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
std::cout << message.toStdString() << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Syslog::ErrorLog(QString Message)
|
||||||
|
{
|
||||||
|
Syslog::Log("ERROR: " + Message, StikkitLogType_Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Syslog::WarningLog(QString Message)
|
||||||
|
{
|
||||||
|
Syslog::Log("WARNING: " + Message, StikkitLogType_Warn);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Syslog::DebugLog(QString Message, unsigned int Verbosity)
|
||||||
|
{
|
||||||
|
if (Configuration::Verbosity >= Verbosity)
|
||||||
|
{
|
||||||
|
Syslog::Log("DEBUG[" + QString::number(Verbosity) + "]: " + Message, StikkitLogType_Debug);
|
||||||
|
}
|
||||||
|
}
|
43
stikkit/syslog.hpp
Normal file
43
stikkit/syslog.hpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
//This program is free software: you can redistribute it and/or modify
|
||||||
|
//it under the terms of the GNU General Public License as published by
|
||||||
|
//the Free Software Foundation, either version 3 of the License, or
|
||||||
|
//(at your option) any later version.
|
||||||
|
|
||||||
|
//This program 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 General Public License for more details.
|
||||||
|
|
||||||
|
#ifndef SYSLOG_HPP
|
||||||
|
#define SYSLOG_HPP
|
||||||
|
|
||||||
|
#include <QFile>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
namespace Stikkit
|
||||||
|
{
|
||||||
|
enum StikkitLogType
|
||||||
|
{
|
||||||
|
StikkitLogType_Normal,
|
||||||
|
StikkitLogType_Error,
|
||||||
|
StikkitLogType_Debug,
|
||||||
|
StikkitLogType_Warn
|
||||||
|
};
|
||||||
|
|
||||||
|
//! Provides a logging to various places
|
||||||
|
class Syslog
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
//! Write text to terminal as well as ring log
|
||||||
|
/*!
|
||||||
|
* \param Message Message to log
|
||||||
|
*/
|
||||||
|
static void Log(QString Message, StikkitLogType Type = StikkitLogType_Normal);
|
||||||
|
static void ErrorLog(QString Message);
|
||||||
|
static void WarningLog(QString Message);
|
||||||
|
//! This log is only shown if verbosity is same or larger than requested verbosity
|
||||||
|
static void DebugLog(QString Message, unsigned int Verbosity = 1);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // SYSLOG_HPP
|
5
stikkit/terminalparser.cpp
Normal file
5
stikkit/terminalparser.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#include "terminalparser.hpp"
|
||||||
|
|
||||||
|
terminalparser::terminalparser()
|
||||||
|
{
|
||||||
|
}
|
10
stikkit/terminalparser.hpp
Normal file
10
stikkit/terminalparser.hpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef TERMINALPARSER_HPP
|
||||||
|
#define TERMINALPARSER_HPP
|
||||||
|
|
||||||
|
class terminalparser
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
terminalparser();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // TERMINALPARSER_HPP
|
5
stikkit/webquery.cpp
Normal file
5
stikkit/webquery.cpp
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
#include "webquery.hpp"
|
||||||
|
|
||||||
|
WebQuery::WebQuery()
|
||||||
|
{
|
||||||
|
}
|
10
stikkit/webquery.hpp
Normal file
10
stikkit/webquery.hpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#ifndef WEBQUERY_HPP
|
||||||
|
#define WEBQUERY_HPP
|
||||||
|
|
||||||
|
class WebQuery
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WebQuery();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // WEBQUERY_HPP
|
Loading…
x
Reference in New Issue
Block a user