mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
bugfix, reworked timestamps and minor tweaks
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
ddfdb66206
commit
fed5f32723
@ -274,11 +274,15 @@ var LoggerActions = actions.Actions({
|
||||
this.log
|
||||
&& this.log.splice(0, this.log.length)
|
||||
return this },
|
||||
print: function(){
|
||||
return this.log ?
|
||||
print: function(to_console){
|
||||
to_console = to_console === undefined ?
|
||||
true
|
||||
: to_console
|
||||
var str = this.log ?
|
||||
this.log
|
||||
.map(function([path, status, rest]){
|
||||
return path.join(': ') + (path.length > 0 ? ': ' : '')
|
||||
.map(function([date, path, status, rest]){
|
||||
return `[${ new Date(date).getTimeStamp(true) }] `
|
||||
+ path.join(': ') + (path.length > 0 ? ': ' : '')
|
||||
+ status
|
||||
+ (rest.length > 1 ?
|
||||
':\n\t'
|
||||
@ -287,7 +291,10 @@ var LoggerActions = actions.Actions({
|
||||
: '')
|
||||
+ rest.join(': ') })
|
||||
.join('\n')
|
||||
: '' },
|
||||
: ''
|
||||
return to_console ?
|
||||
(console.log(str), this)
|
||||
: str },
|
||||
|
||||
|
||||
// main API...
|
||||
@ -313,10 +320,13 @@ var LoggerActions = actions.Actions({
|
||||
emit: function(status, ...rest){
|
||||
// write to log...
|
||||
this.log !== false
|
||||
&& this.log.push([this.path, status, rest])
|
||||
&& this.log.push([
|
||||
Date.now(),
|
||||
this.path,
|
||||
status,
|
||||
rest])
|
||||
// maintain log size...
|
||||
this.log !== false
|
||||
&& this.log.push([this.path, status, rest])
|
||||
&& (this.max_size > 0
|
||||
&& this.log.length > this.max_size
|
||||
&& this.log.splice(0, this.log.length - this.max_size))
|
||||
@ -829,6 +839,9 @@ module.LifeCycle = ImageGridFeatures.Feature({
|
||||
doc: '',
|
||||
|
||||
tag: 'lifecycle',
|
||||
suggested: [
|
||||
'logger',
|
||||
],
|
||||
priority: 'high',
|
||||
|
||||
actions: LifeCycleActions,
|
||||
@ -2289,6 +2302,9 @@ module.SelfTest = ImageGridFeatures.Feature({
|
||||
depends: [
|
||||
'lifecycle'
|
||||
],
|
||||
suggested: [
|
||||
'logger',
|
||||
],
|
||||
priority: 'low',
|
||||
|
||||
actions: SelfTestActions,
|
||||
|
||||
@ -25,7 +25,6 @@ core.ImageGridFeatures.Feature('imagegrid-commandline', [
|
||||
|
||||
core.ImageGridFeatures.Feature('imagegrid-minimal', [
|
||||
'lifecycle',
|
||||
'logger', // XXX
|
||||
'alias',
|
||||
'peer',
|
||||
'fs',
|
||||
|
||||
@ -333,36 +333,28 @@ var patchDate =
|
||||
module.patchDate = function(date){
|
||||
date = date || Date
|
||||
|
||||
date.prototype.toShortDate = function(){
|
||||
var y = this.getFullYear()
|
||||
var M = this.getMonth()+1
|
||||
M = M < 10 ? '0'+M : M
|
||||
var D = this.getDate()
|
||||
D = D < 10 ? '0'+D : D
|
||||
var H = this.getHours()
|
||||
H = H < 10 ? '0'+H : H
|
||||
var m = this.getMinutes()
|
||||
m = m < 10 ? '0'+m : m
|
||||
var s = this.getSeconds()
|
||||
s = s < 10 ? '0'+s : s
|
||||
|
||||
return ''+y+'-'+M+'-'+D+' '+H+':'+m+':'+s
|
||||
}
|
||||
date.prototype.getTimeStamp = function(no_seconds){
|
||||
var y = this.getFullYear()
|
||||
var M = this.getMonth()+1
|
||||
M = M < 10 ? '0'+M : M
|
||||
var D = this.getDate()
|
||||
D = D < 10 ? '0'+D : D
|
||||
var H = this.getHours()
|
||||
H = H < 10 ? '0'+H : H
|
||||
var m = this.getMinutes()
|
||||
m = m < 10 ? '0'+m : m
|
||||
var s = this.getSeconds()
|
||||
s = s < 10 ? '0'+s : s
|
||||
|
||||
return ''+y+M+D+H+m+s
|
||||
}
|
||||
date.prototype.toShortDate = function(show_ms){
|
||||
return ''
|
||||
+ this.getFullYear()
|
||||
+'-'+ ('0'+this.getMonth()+1).slice(-2)
|
||||
+'-'+ ('0'+this.getDate()).slice(-2)
|
||||
+' '+ ('0'+this.getHours()).slice(-2)
|
||||
+':'+ ('0'+this.getMinutes()).slice(-2)
|
||||
+':'+ ('0'+this.getSeconds()).slice(-2)
|
||||
+ (show_ms ?
|
||||
':'+(('000'+this.getMilliseconds()).slice(-3))
|
||||
: '') }
|
||||
date.prototype.getTimeStamp = function(show_ms){
|
||||
return ''
|
||||
+ this.getFullYear()
|
||||
+ ('0'+this.getMonth()+1).slice(-2)
|
||||
+ ('0'+this.getDate()).slice(-2)
|
||||
+ ('0'+this.getHours()).slice(-2)
|
||||
+ ('0'+this.getMinutes()).slice(-2)
|
||||
+ ('0'+this.getSeconds()).slice(-2)
|
||||
+ (show_ms ?
|
||||
('000'+this.getMilliseconds()).slice(-3)
|
||||
: '') }
|
||||
date.prototype.setTimeStamp = function(ts){
|
||||
ts = ts.replace(/[^0-9]*/g, '')
|
||||
this.setFullYear(ts.slice(0, 4))
|
||||
@ -371,14 +363,12 @@ module.patchDate = function(date){
|
||||
this.setHours(ts.slice(8, 10))
|
||||
this.setMinutes(ts.slice(10, 12))
|
||||
this.setSeconds(ts.slice(12, 14))
|
||||
return this
|
||||
}
|
||||
date.timeStamp = function(){
|
||||
return (new this()).getTimeStamp()
|
||||
}
|
||||
this.setMilliseconds(ts.slice(14, 17) || 0)
|
||||
return this }
|
||||
date.timeStamp = function(...args){
|
||||
return (new this()).getTimeStamp(...args) }
|
||||
date.fromTimeStamp = function(ts){
|
||||
return (new this()).setTimeStamp(ts)
|
||||
}
|
||||
return (new this()).setTimeStamp(ts) }
|
||||
// convert string time period to milliseconds...
|
||||
date.str2ms = function(str, dfl){
|
||||
dfl = dfl || 'ms'
|
||||
|
||||
@ -117,6 +117,4 @@ $(function(){
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* vim:set ts=4 sw=4 : */
|
||||
return module })
|
||||
//})
|
||||
* vim:set ts=4 sw=4 : */ return module })
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user