Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Chakra
Akabei
Akabei core library
Commits
96f1cc0b
Commit
96f1cc0b
authored
Jul 10, 2012
by
Lukas Appelhans
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement retrieveLoggedActions
parent
cb82ff1f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
3 deletions
+36
-3
lib/akabeilog.cpp
lib/akabeilog.cpp
+30
-1
lib/akabeilog.h
lib/akabeilog.h
+3
-1
lib/akabeipackage.cpp
lib/akabeipackage.cpp
+3
-1
No files found.
lib/akabeilog.cpp
View file @
96f1cc0b
...
...
@@ -16,11 +16,14 @@
#include <syslog.h>
#include <QDateTime>
#include <QTextStream>
#include <QFile>
namespace
{
/* These are required to hold the configuration between calls */
static
std
::
ofstream
logStream
;
static
bool
isSyslog
(
false
);
static
QString
pathToFile
;
static
QString
__msg_prefix
[]
=
{
""
,
"Warning: "
,
"Critical: "
};
static
int
__msg_priority
[]
=
{
LOG_WARNING
,
LOG_WARNING
,
LOG_CRIT
};
...
...
@@ -74,13 +77,14 @@ AkabeiLogLine::~AkabeiLogLine()
/*
* This must be called before using the logging system
*/
void
AkabeiLogLine
::
initialize
(
bool
syslog
,
QString
filename
)
void
AkabeiLogLine
::
initialize
(
bool
syslog
,
const
QString
&
filename
)
{
isSyslog
=
syslog
;
if
(
isSyslog
)
{
openlog
(
"akabei"
,
LOG_PID
|
LOG_CONS
,
LOG_USER
);
/* open connection for a generic user service */
}
else
{
pathToFile
=
filename
;
logStream
.
open
(
filename
.
toUtf8
().
constData
(),
std
::
ios
::
app
);
if
(
!
logStream
.
is_open
())
{
...
...
@@ -230,3 +234,28 @@ AkabeiLogLine log()
return
AkabeiLogLine
(
LogNormal
);
}
QString
readLoggedActions
(
const
QString
&
filter
)
{
if
(
isSyslog
)
return
QString
();
if
(
pathToFile
.
isEmpty
())
{
std
::
cerr
<<
"Log error: logging system not initialized correctly. Cannot read from log."
<<
std
::
endl
;
return
QString
();
}
QString
result
;
QFile
file
(
pathToFile
);
if
(
!
file
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
return
QString
();
QTextStream
in
(
&
file
);
while
(
!
in
.
atEnd
())
{
QString
line
=
in
.
readLine
();
if
(
line
.
contains
(
filter
))
result
.
append
(
line
+
"
\n
"
);
}
return
result
;
}
lib/akabeilog.h
View file @
96f1cc0b
...
...
@@ -45,7 +45,7 @@ public:
AkabeiLogLine
&
operator
<<
(
const
QByteArray
&
);
AkabeiLogLine
&
operator
<<
(
const
void
*
);
static
void
initialize
(
bool
syslog
,
QString
filename
=
QString
());
static
void
initialize
(
bool
syslog
,
const
QString
&
filename
=
QString
());
private:
class
Private
;
...
...
@@ -56,4 +56,6 @@ AkabeiLogLine logWarning();
AkabeiLogLine
logCritical
();
AkabeiLogLine
log
();
QString
readLoggedActions
(
const
QString
&
filter
);
#endif
lib/akabeipackage.cpp
View file @
96f1cc0b
...
...
@@ -24,6 +24,8 @@
#include <QFile>
#include <QDir>
#include <akabeidebug.h>
#include <akabeipackage.h>
#include <akabeilog.h>
namespace
Akabei
{
void
PackagePrivate
::
setName
(
const
QString
&
n
)
...
...
@@ -448,7 +450,7 @@ QString Package::retrieveLoggedActions() const
{
Q_D
(
const
Package
);
QWriteLocker
locker
(
d
->
mutex
);
return
QString
();
return
readLoggedActions
(
' '
+
d
->
name
+
' '
);
//We have empty spaces around, otherwise we will e.g. get all the apr-utils log lines for apr as well
}
QStringList
Package
::
conflictsWith
()
const
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment