mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-01-22 23:08:13 -05:00
Trim the log if new logs cannot be written to storage. Fix #1288.
This commit is contained in:
parent
adb4cad27d
commit
aac049d559
@ -4,14 +4,23 @@ Promise.longStackTraces()
|
|||||||
|
|
||||||
OmegaTargetCurrent.Log = Object.create(OmegaTargetCurrent.Log)
|
OmegaTargetCurrent.Log = Object.create(OmegaTargetCurrent.Log)
|
||||||
Log = OmegaTargetCurrent.Log
|
Log = OmegaTargetCurrent.Log
|
||||||
|
|
||||||
|
_writeLogToLocalStorage = (content) ->
|
||||||
|
try
|
||||||
|
localStorage['log'] += content
|
||||||
|
catch
|
||||||
|
# Maybe we have reached our limit here. See #1288. Try trimming it.
|
||||||
|
localStorage['log'] = content
|
||||||
|
|
||||||
Log.log = (args...) ->
|
Log.log = (args...) ->
|
||||||
console.log(args...)
|
console.log(args...)
|
||||||
localStorage['log'] += args.map(Log.str.bind(Log)).join(' ') + '\n'
|
content = args.map(Log.str.bind(Log)).join(' ') + '\n'
|
||||||
|
_writeLogToLocalStorage(content)
|
||||||
Log.error = (args...) ->
|
Log.error = (args...) ->
|
||||||
console.error(args...)
|
console.error(args...)
|
||||||
content = args.map(Log.str.bind(Log)).join(' ')
|
content = args.map(Log.str.bind(Log)).join(' ')
|
||||||
localStorage['logLastError'] = content
|
localStorage['logLastError'] = content
|
||||||
localStorage['log'] += 'ERROR: ' + content + '\n'
|
_writeLogToLocalStorage('ERROR: ' + content + '\n')
|
||||||
|
|
||||||
unhandledPromises = []
|
unhandledPromises = []
|
||||||
unhandledPromisesId = []
|
unhandledPromisesId = []
|
||||||
|
Loading…
Reference in New Issue
Block a user