Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kumir2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
2
Issues
2
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
kumir
kumir2
Commits
ed798e47
Commit
ed798e47
authored
Apr 21, 2015
by
Victor Yacovlev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for #kumir2-1897
parent
19aa53e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
4 deletions
+38
-4
src/shared/extensionsystem/logger.cpp
src/shared/extensionsystem/logger.cpp
+37
-4
src/shared/extensionsystem/logger.h
src/shared/extensionsystem/logger.h
+1
-0
No files found.
src/shared/extensionsystem/logger.cpp
View file @
ed798e47
...
...
@@ -49,7 +49,7 @@ Logger::Logger(const QString & filePath, LogLevel logLevel)
#ifdef NDEBUG
bool
process
=
Debug
==
logLevel_
;
#else
bool
process
=
true
;
bool
process
=
isDebugOnLinux
()
;
#endif
if
(
process
)
{
writeLog
(
"STARTED"
,
""
);
...
...
@@ -61,7 +61,7 @@ Logger::~Logger()
#ifdef NDEBUG
bool
process
=
Debug
==
logLevel_
;
#else
bool
process
=
true
;
bool
process
=
isDebugOnLinux
()
;
#endif
if
(
process
)
{
writeLog
(
"EXITING"
,
""
);
...
...
@@ -73,6 +73,39 @@ Logger::~Logger()
}
}
static
bool
isUbuntu
()
{
#ifndef Q_OS_LINUX
return
false
;
#endif
QFile
osRelease
(
"/etc/os-release"
);
if
(
osRelease
.
open
(
QIODevice
::
ReadOnly
|
QIODevice
::
Text
))
{
QByteArray
content
=
osRelease
.
readAll
();
osRelease
.
close
();
return
content
.
contains
(
"ID=ubuntu"
);
}
return
false
;
}
static
bool
isInstalledInPosixSystem
()
{
#ifndef Q_OS_UNIX
return
false
;
#endif
const
QString
appDir
=
QCoreApplication
::
applicationDirPath
();
return
appDir
.
startsWith
(
"/usr/"
)
||
appDir
.
startsWith
(
"/opt/"
);
}
bool
Logger
::
isDebugOnLinux
()
{
#ifndef Q_OS_UNIX
return
true
;
#endif
// Check once
static
const
bool
ubuntu
=
isUbuntu
();
static
const
bool
usrRoot
=
isInstalledInPosixSystem
();
static
const
bool
ubuntuPackage
=
ubuntu
&&
usrRoot
;
return
!
ubuntuPackage
;
}
void
Logger
::
writeLog
(
const
char
*
type
,
const
QString
&
message
)
{
QByteArray
buffer
;
...
...
@@ -96,7 +129,7 @@ void Logger::debug(const QString &message)
#ifdef NDEBUG
bool
process
=
Debug
==
logLevel_
;
#else
bool
process
=
true
;
bool
process
=
isDebugOnLinux
()
;
#endif
if
(
process
)
{
writeLog
(
"DEBUG"
,
message
);
...
...
@@ -108,7 +141,7 @@ void Logger::warning(const QString &message)
#ifdef NDEBUG
bool
process
=
Debug
==
logLevel_
;
#else
bool
process
=
true
;
bool
process
=
isDebugOnLinux
()
;
#endif
if
(
process
)
{
writeLog
(
"WARNING"
,
message
);
...
...
src/shared/extensionsystem/logger.h
View file @
ed798e47
...
...
@@ -34,6 +34,7 @@ public:
~
Logger
();
private:
static
bool
isDebugOnLinux
();
void
writeLog
(
const
char
*
type
,
const
QString
&
message
);
Logger
(
const
QString
&
filePath
,
LogLevel
logLevel
);
...
...
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