Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
les
gancio
Commits
9cf2b41f
Verified
Commit
9cf2b41f
authored
Jul 08, 2021
by
les
Browse files
improve error logging
parent
1cd43f89
Changes
14
Hide whitespace changes
Inline
Side-by-side
server/api/controller/event.js
View file @
9cf2b41f
...
...
@@ -118,7 +118,7 @@ const eventController = {
order
:
[[
Resource
,
'
id
'
,
'
DESC
'
]]
})
}
catch
(
e
)
{
log
.
error
(
e
)
log
.
error
(
'
[EVENT]
'
,
e
)
return
res
.
sendStatus
(
400
)
}
...
...
@@ -194,7 +194,7 @@ const eventController = {
const
notifier
=
require
(
'
../../notifier
'
)
notifier
.
notifyEvent
(
'
Create
'
,
event
.
id
)
}
catch
(
e
)
{
log
.
error
(
e
)
log
.
error
(
'
[EVENT]
'
,
e
)
res
.
sendStatus
(
404
)
}
},
...
...
@@ -334,7 +334,7 @@ const eventController = {
notifier
.
notifyEvent
(
'
Create
'
,
event
.
id
)
}
}
catch
(
e
)
{
log
.
error
(
e
)
log
.
error
(
'
[EVENT ADD]
'
,
e
)
res
.
sendStatus
(
400
)
}
},
...
...
@@ -419,6 +419,7 @@ const eventController = {
}
const
notifier
=
require
(
'
../../notifier
'
)
await
notifier
.
notifyEvent
(
'
Delete
'
,
event
.
id
)
log
.
debug
(
'
[EVENT REMOVED]
'
,
event
.
title
)
await
event
.
destroy
()
res
.
sendStatus
(
200
)
}
else
{
...
...
@@ -474,7 +475,8 @@ const eventController = {
{
model
:
Place
,
required
:
true
,
attributes
:
[
'
id
'
,
'
name
'
,
'
address
'
]
}
]
}).
catch
(
e
=>
{
log
.
error
(
e
)
log
.
error
(
'
[EVENT]
'
,
e
)
return
[]
})
return
events
.
map
(
e
=>
{
...
...
server/api/controller/oauth.js
View file @
9cf2b41f
...
...
@@ -42,7 +42,7 @@ const oauthController = {
delete
client
.
id
res
.
json
(
client
)
}
catch
(
e
)
{
log
.
error
(
e
)
log
.
error
(
'
[OAUTH CLIENT]
'
,
e
)
res
.
status
(
400
).
json
(
e
)
}
},
...
...
server/api/controller/settings.js
View file @
9cf2b41f
...
...
@@ -103,7 +103,7 @@ const settingsController = {
settingsController
[
is_secret
?
'
secretSettings
'
:
'
settings
'
][
key
]
=
value
return
true
}
catch
(
e
)
{
log
.
error
(
e
)
log
.
error
(
'
[SETTING SET]
'
,
e
)
return
false
}
},
...
...
@@ -129,7 +129,7 @@ const settingsController = {
.
png
({
quality
:
90
})
.
toFile
(
baseImgPath
+
'
.png
'
,
async
(
err
,
info
)
=>
{
if
(
err
)
{
log
.
error
(
err
)
log
.
error
(
'
[LOGO]
'
,
err
)
}
const
image
=
await
readFile
(
baseImgPath
+
'
.png
'
)
const
favicon
=
await
toIco
([
image
],
{
sizes
:
[
64
],
resize
:
true
})
...
...
server/api/controller/user.js
View file @
9cf2b41f
...
...
@@ -103,7 +103,7 @@ const userController = {
mail
.
send
(
config
.
admin_email
,
'
admin_register
'
,
{
user
,
config
})
res
.
sendStatus
(
200
)
}
catch
(
e
)
{
log
.
error
(
'
Registration error:
"%s"
'
,
e
)
log
.
error
(
'
Registration error:
'
,
e
)
res
.
status
(
404
).
json
(
e
)
}
},
...
...
@@ -116,7 +116,7 @@ const userController = {
mail
.
send
(
user
.
email
,
'
user_confirm
'
,
{
user
,
config
},
req
.
settings
.
locale
)
res
.
json
(
user
)
}
catch
(
e
)
{
log
.
error
(
'
User creation error:
%s
'
,
e
)
log
.
error
(
'
User creation error:
'
,
e
)
res
.
status
(
404
).
json
(
e
)
}
},
...
...
@@ -127,7 +127,7 @@ const userController = {
user
.
destroy
()
res
.
sendStatus
(
200
)
}
catch
(
e
)
{
log
.
error
(
'
User removal error:
"%s
"
'
,
e
)
log
.
error
(
'
User removal error:"
'
,
e
)
res
.
status
(
404
).
json
(
e
)
}
}
...
...
server/api/index.js
View file @
9cf2b41f
...
...
@@ -145,7 +145,7 @@ api.use((req, res) => res.sendStatus(404))
// Handle 500
api
.
use
((
error
,
req
,
res
,
next
)
=>
{
log
.
error
(
error
)
log
.
error
(
'
[API ERROR]
'
,
error
)
res
.
status
(
500
).
send
(
'
500: Internal Server Error
'
)
})
...
...
server/api/mail.js
View file @
9cf2b41f
...
...
@@ -61,7 +61,7 @@ const mail = {
}
return
email
.
send
(
msg
)
.
catch
(
e
=>
{
log
.
error
(
'
Error sending email => %s
'
,
e
)
log
.
error
(
'
[MAIL]
'
,
e
)
})
}
}
...
...
server/api/oauth.js
View file @
9cf2b41f
...
...
@@ -34,7 +34,7 @@ oauth.use((req, res) => res.sendStatus(404))
oauth
.
use
((
err
,
req
,
res
,
next
)
=>
{
const
error_msg
=
err
.
toString
()
log
.
error
(
error_msg
)
log
.
error
(
'
[OAUTH USE]
'
,
error_msg
)
res
.
status
(
500
).
send
(
error_msg
)
})
...
...
server/api/storage.js
View file @
9cf2b41f
...
...
@@ -8,9 +8,7 @@ const config = require('config')
try
{
mkdirp
.
sync
(
config
.
upload_path
+
'
/thumb
'
)
}
catch
(
e
)
{
log
.
error
(
e
)
}
}
catch
(
e
)
{}
const
DiskStorage
=
{
_handleFile
(
req
,
file
,
cb
)
{
...
...
@@ -25,11 +23,11 @@ const DiskStorage = {
let
onError
=
false
const
err
=
e
=>
{
if
(
onError
)
{
log
.
error
(
err
)
log
.
error
(
'
[UPLOAD]
'
,
err
)
return
}
onError
=
true
log
.
error
(
e
)
log
.
error
(
'
[UPLOAD]
'
,
e
)
req
.
err
=
e
cb
(
null
)
}
...
...
server/federation/helpers.js
View file @
9cf2b41f
...
...
@@ -126,7 +126,7 @@ const Helpers = {
return
res
.
data
})
.
catch
(
e
=>
{
log
.
error
(
`
${
URL
}
:
${
e
}
`
)
log
.
error
(
`
get Actor
${
URL
}
`
,
e
)
return
false
})
...
...
server/federation/webfinger.js
View file @
9cf2b41f
...
...
@@ -140,7 +140,7 @@ router.use((req, res) => {
// Handle 500
router
.
use
((
error
,
req
,
res
,
next
)
=>
{
log
.
error
(
error
)
log
.
error
(
'
[WEBFINGER]
'
,
error
)
res
.
status
(
500
).
send
(
'
500: Internal Server Error
'
)
})
...
...
server/helpers.js
View file @
9cf2b41f
...
...
@@ -163,8 +163,8 @@ module.exports = {
}))
}
}
catch
(
e
)
{
log
.
error
(
e
)
res
.
status
(
400
).
json
(
e
.
toString
)
log
.
error
(
'
[Import URL]
'
,
e
)
res
.
status
(
400
).
json
(
e
.
toString
()
)
}
},
...
...
server/log.js
View file @
9cf2b41f
const
{
createLogger
,
transports
,
format
}
=
require
(
'
winston
'
)
const
DailyRotateFile
=
require
(
'
winston-daily-rotate-file
'
)
const
dayjs
=
require
(
'
dayjs
'
)
//
const dayjs = require('dayjs')
const
config
=
require
(
'
config
'
)
const
gancioFormat
=
format
.
printf
(({
timestamp
,
level
,
message
,
error
})
=>
{
return
`
${
dayjs
(
timestamp
).
format
(
'
DD MMM YYYY HH:mm:ss
'
)}
${
level
}
:
${
message
}
`
const
gancioFormat
=
format
.
printf
(
info
=>
{
if
(
info
.
stack
)
{
return
`
${
info
.
timestamp
}
${
info
.
level
}
:
${
info
.
message
}
\r\n
${
info
.
stack
}
`
}
else
{
return
`
${
info
.
timestamp
}
${
info
.
level
}
:
${
info
.
message
}
`
}
})
const
logger
=
createLogger
({
...
...
@@ -12,15 +16,11 @@ const logger = createLogger({
transports
:
process
.
env
.
NODE_ENV
!==
'
production
'
?
[
new
transports
.
Console
(
{
handleExceptions
:
true
,
handleRejections
:
true
,
level
:
'
debug
'
,
format
:
format
.
combine
(
format
.
errors
({
stack
:
true
}
),
format
.
timestamp
(),
format
.
colorize
(),
format
.
splat
(),
gancioFormat
)
format
:
format
.
combine
(
format
.
splat
(
),
format
.
timestamp
(),
format
.
colorize
(),
gancioFormat
)
}
)]
:
[
new
DailyRotateFile
({
handleExceptions
:
true
,
handleRejections
:
true
,
level
:
config
.
log_level
||
'
info
'
,
filename
:
config
.
log_path
+
'
/gancio.%DATE%.log
'
,
symlinkName
:
'
gancio.log
'
,
...
...
@@ -28,14 +28,12 @@ const logger = createLogger({
zippedArchive
:
true
,
maxSize
:
'
10m
'
,
maxFiles
:
'
10d
'
,
format
:
format
.
combine
(
format
.
timestamp
(),
format
.
splat
(),
gancioFormat
)
format
:
format
.
combine
(
format
.
timestamp
(),
gancioFormat
)
}),
new
transports
.
Console
(
{
handleExceptions
:
true
,
handleRejections
:
true
,
level
:
config
.
log_level
||
'
info
'
,
format
:
format
.
combine
(
format
.
timestamp
(),
format
.
splat
(),
format
.
colorize
(),
gancioFormat
)
format
:
format
.
combine
(
format
.
timestamp
(),
format
.
colorize
(),
gancioFormat
)
}
)]
})
...
...
server/notifier.js
View file @
9cf2b41f
...
...
@@ -51,7 +51,7 @@ const notifier = {
await
notifier
.
sendNotification
(
notification
,
event
)
notification
.
event_notification
.
status
=
'
sent
'
}
catch
(
err
)
{
log
.
error
(
err
)
log
.
error
(
'
[NOTIFY EVENT]
'
,
err
)
notification
.
event_notification
.
status
=
'
error
'
}
return
notification
.
event_notification
.
save
()
...
...
@@ -71,7 +71,7 @@ const notifier = {
e
.
status
=
'
sent
'
return
e
.
save
()
}
catch
(
err
)
{
log
.
error
(
err
)
log
.
error
(
'
[NOTIFY]
'
,
err
)
e
.
status
=
'
error
'
e
.
error
=
err
return
e
.
save
()
...
...
server/routes.js
View file @
9cf2b41f
...
...
@@ -61,7 +61,7 @@ app.use('/oauth', oauth)
// // Handle 500
app
.
use
((
error
,
req
,
res
,
next
)
=>
{
log
.
error
(
error
)
log
.
error
(
'
[ERROR]
'
,
error
)
res
.
status
(
500
).
send
(
'
500: Internal Server Error
'
)
})
...
...
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