Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
marcus-lodspeakr
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
uib-ub
Spesialsamlingene
marcus-lodspeakr
Commits
845bf103
"git@git.app.uib.no:Margunn.Rauset/beta.ordbok.uib.no.git" did not exist on "39ec922a43486691281f944fea5360ce9893c9e4"
Commit
845bf103
authored
11 years ago
by
alvaro
Browse files
Options
Downloads
Patches
Plain Diff
improved logging
parent
b92b9d20
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
README.md
+1
-1
1 addition, 1 deletion
README.md
classes/Logging.php
+59
-3
59 additions, 3 deletions
classes/Logging.php
common.inc.php
+1
-1
1 addition, 1 deletion
common.inc.php
index.php
+1
-10
1 addition, 10 deletions
index.php
with
62 additions
and
15 deletions
README.md
+
1
−
1
View file @
845bf103
...
...
@@ -3,7 +3,7 @@ LODSPeaKr
author: Alvaro Graves (alvaro@graves.cl)
version: 20130
215
version: 20130
513
[
LODSPeaKr
](
http://lodspeakr.org
)
is a framework for creating Linked Data applications in a simple and easy way. You can see
[
several applications
](
http://alangrafu.github.com/lodspeakr/applications.html
)
created using LODSPeaKr.
...
...
This diff is collapsed.
Click to expand it.
classes/Logging.php
+
59
−
3
View file @
845bf103
...
...
@@ -14,8 +14,27 @@ class Logging{
}
sort
(
$logs
);
$alogs
=
""
;
$list
=
array
();
foreach
(
$logs
as
$v
){
$alogs
.
=
"<p><a href='#lodspeakr/cache/
$v
'>
$v
</a></p>"
;
$newtokens
=
array
(
"."
,
"/"
);
$oldtokens
=
array
(
"___DOT___"
,
"___SLASH___"
);
$label
=
str_replace
(
$oldtokens
,
$newtokens
,
$v
);
$x
=
explode
(
"_"
,
$label
);
$y
=
array_shift
(
$x
);
array_shift
(
$x
);
if
(
!
isset
(
$list
[
$y
])){
$list
[
$y
]
=
array
();
}
$list
[
$y
][]
=
array
(
"name"
=>
implode
(
"_"
,
$x
),
"url"
=>
$v
);
//$alogs .= "<p><a href='#lodspeakr/cache/$v'>$label</a></p>";
}
ksort
(
$list
);
foreach
(
$list
as
$k
=>
$v
){
$alogs
.
=
"<li>"
.
date
(
"H:i:s"
,
$k
)
.
"<ul>
\n
"
;
foreach
(
$v
as
$w
){
$alogs
.
=
" <li><a href='#lodspeakr/cache/"
.
$w
[
'url'
]
.
"'>"
.
$w
[
'name'
]
.
"</a></li>
\n
"
;
}
$alogs
.
=
"</ul></li>"
;
}
echo
"
<!DOCTYPE html>
...
...
@@ -28,6 +47,10 @@ class Logging{
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
}
.bold{
font-weight: bold;
font-size: 120%;
}
</style>
<link href='css/bootstrap-responsive.min.css' rel='stylesheet' type='text/css' media='screen' />
<script type='text/javascript' src='js/jquery.js'></script>
...
...
@@ -54,13 +77,25 @@ class Logging{
<div class='row'>
<div class='span4 well'>
<h3>Logs</h3>
<!--div>
<select id='level'>
<option value='0'>All</option>
<option value='1'>Notice</option>
<option value='2'>Error</option>
</select>
</div-->
<ul>
$alogs
</ul>
</div>
<div class='span8' id='log'>
</div>
</div>
<script>
$('a').on('click', function(){
$('a').on('click', function(e){
$('a').removeClass('bold');
$(e.target).addClass('bold');
var link = $(this).attr('href').replace('#', '');
$.ajax({
url: link,
...
...
@@ -68,7 +103,14 @@ class Logging{
success: function(data){
var pres = '';
$.each(data.logs, function(i, item){
pres += '<h4>'+item.timestamp+'</h4><pre>'+item.message+'</pre>';
var date = new Date(item.timestamp * 1000),
dateFormatted = date.getFullYear()+'/'+
(date.getMonth()+1)+'/'+
date.getDate()+' '+
date.getHours()+':'+
date.getMinutes()+':'+
date.getSeconds();
pres += '<h4>On '+dateFormatted+'</h4><pre>'+item.message+'</pre>';
});
$('#log').html(pres);
}
...
...
@@ -86,4 +128,18 @@ class Logging{
fwrite
(
$conf
[
'logfile'
],
", "
.
json_encode
(
$log
));
}
}
public
static
function
createLogFile
(
$url
){
$oldtokens
=
array
(
"."
,
"/"
);
$newtokens
=
array
(
"___DOT___"
,
"___SLASH___"
);
$filename
=
str_replace
(
$oldtokens
,
$newtokens
,
$url
);
$logfile
=
fopen
(
"cache/"
.
time
()
.
"_"
.
rand
()
.
"_"
.
$filename
.
".log"
,
"w"
);
if
(
$logfile
===
FALSE
){
die
(
"Can't create log file. Check permissions in <tt>cache/</tt> directory."
);
}
$initialmsg
=
array
(
'timestamp'
=>
time
(),
'message'
=>
"Starting log for "
.
$url
);
fwrite
(
$logfile
,
"{
\"
logs
\"
: ["
.
json_encode
(
$initialmsg
));
return
$logfile
;
}
}
This diff is collapsed.
Click to expand it.
common.inc.php
+
1
−
1
View file @
845bf103
<?php
$conf
[
'version'
]
=
'20130
215
'
;
$conf
[
'version'
]
=
'20130
513
'
;
$conf
[
'output'
][
'select'
]
=
'json'
;
$conf
[
'output'
][
'ask'
]
=
'json'
;
$conf
[
'output'
][
'describe'
]
=
'rdf'
;
...
...
This diff is collapsed.
Click to expand it.
index.php
+
1
−
10
View file @
845bf103
...
...
@@ -24,16 +24,7 @@ if($conf['debug']){
Logging
::
init
();
exit
(
0
);
}
else
{
$oldtokens
=
array
(
"."
,
"/"
);
$newtokens
=
array
(
"_"
,
"_"
);
$filename
=
str_replace
(
$oldtokens
,
$newtokens
,
$_GET
[
'q'
]);
$conf
[
'logfile'
]
=
fopen
(
"cache/"
.
$filename
.
"_"
.
time
()
.
rand
()
.
".log"
,
"w"
);
if
(
$conf
[
'logfile'
]
===
FALSE
){
die
(
"Can't create log file. Check permissions in <tt>cache/</tt> directory."
);
}
$initialmsg
=
array
(
'timestamp'
=>
time
(),
'message'
=>
"Log for "
.
$_GET
[
'q'
]);
fwrite
(
$conf
[
'logfile'
],
"{
\"
logs
\"
: ["
.
json_encode
(
$initialmsg
));
$conf
[
'logfile'
]
=
Logging
::
createLogFile
(
$_GET
[
'q'
]);
//error_reporting(E_ALL);
}
}
else
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment