Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
7e40f599
Commit
7e40f599
authored
Feb 21, 2016
by
Carsten Rose
Browse files
Logger: Move support::log() to logger::logMessage.
Support: removed Function log(). Database: Use of new class Logger.
parent
551dbd17
Changes
3
Hide whitespace changes
Inline
Side-by-side
extension/qfq/qfq/Database.php
View file @
7e40f599
...
...
@@ -22,6 +22,7 @@ require_once(__DIR__ . '/exceptions/DbException.php');
require_once
(
__DIR__
.
'/store/Store.php'
);
require_once
(
__DIR__
.
'/helper/Support.php'
);
require_once
(
__DIR__
.
'/helper/Logger.php'
);
require_once
(
__DIR__
.
'/helper/BindParam.php'
);
/**
...
...
@@ -50,6 +51,10 @@ class Database {
*/
private
$mysqli_result
=
null
;
/**
* @var string
*/
private
$sqlLog
=
''
;
/**
* Returns current data base handle from Store[System][SYSTEM_DBH].
...
...
@@ -64,6 +69,7 @@ class Database {
if
(
$this
->
mysqli
===
null
)
{
$this
->
mysqli
=
$this
->
dbConnect
();
}
$this
->
sqlLog
=
$this
->
store
->
getVar
(
SYSTEM_SQL_LOG
,
STORE_SYSTEM
);
}
...
...
@@ -379,7 +385,7 @@ class Database {
$msg
.
=
']'
;
Support
::
log
(
$ms
g
);
Logger
::
logMessage
(
$msg
,
$this
->
sqlLo
g
);
}
/**
...
...
extension/qfq/qfq/helper/Logger.php
0 → 100644
View file @
7e40f599
<?php
/**
* Created by PhpStorm.
* User: crose
* Date: 2/18/16
* Time: 5:30 PM
*/
namespace
qfq
;
require_once
(
__DIR__
.
'/../Constants.php'
);
require_once
(
__DIR__
.
'/../exceptions/UserException.php'
);
class
Logger
{
/**
* Haengt $msg an $filename an
*
* @param $msg
* @param $filename
* @throws UserException
*/
public
static
function
logMessage
(
$msg
,
$filename
)
{
if
(
!
$handle
=
fopen
(
$filename
,
'a'
))
{
throw
new
UserException
(
"Error - cannot open. File: "
.
$filename
,
ERROR_IO_OPEN
);
}
if
(
fwrite
(
$handle
,
$msg
.
PHP_EOL
)
===
FALSE
)
{
throw
new
UserException
(
"Error - cannot write. File: "
.
$filename
,
ERROR_IO_WRITE
);
}
fclose
(
$handle
);
}
// logMessage()
}
\ No newline at end of file
extension/qfq/qfq/helper/Support.php
View file @
7e40f599
...
...
@@ -48,25 +48,4 @@ class Support {
return
implode
(
'&'
,
$items
);
}
/**
* @throws CodeException
*/
public
static
function
log
(
$text
)
{
$logFile
=
__DIR__
.
'/../../../'
.
QFQ_LOG
;
if
(
!
is_writable
(
$logFile
))
{
throw
new
CodeException
(
"The file ("
.
dirname
(
$_SERVER
[
'SCRIPT_FILENAME'
])
.
'/) '
.
$logFile
.
" is not writable ()"
,
ERROR_LOG_NOT_WRITABLE
);
}
if
(
!
$handle
=
fopen
(
$logFile
,
'a'
))
{
throw
new
CodeException
(
"Cannot open file to append: "
.
$logFile
,
ERROR_LOG_NOT_WRITABLE
);
}
if
(
fwrite
(
$handle
,
$text
.
chr
(
10
))
===
FALSE
)
{
throw
new
CodeException
(
"Cannot write to file: "
.
$logFile
,
ERROR_LOG_NOT_WRITABLE
);
}
fclose
(
$handle
);
}
}
\ No newline at end of file
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