Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
336
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
23
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TransFem.org
Sharkey
Commits
abb2c375
Commit
abb2c375
authored
3 months ago
by
Hazelnoot
Browse files
Options
Downloads
Patches
Plain Diff
re-implement "reduce inbox log spam when fetching blocked / unavailable notes"
parent
e4047b40
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!842
Bump stable version
,
!837
rethrow everything but non-retryable HTTP errors
Pipeline
#2198
failed with stage
Stage: test
in 8 minutes and 15 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
packages/backend/src/logger.ts
+18
-9
18 additions, 9 deletions
packages/backend/src/logger.ts
packages/backend/src/queue/QueueProcessorService.ts
+1
-1
1 addition, 1 deletion
packages/backend/src/queue/QueueProcessorService.ts
with
19 additions
and
10 deletions
packages/backend/src/logger.ts
+
18
−
9
View file @
abb2c375
...
...
@@ -18,6 +18,9 @@ type Context = {
type
Level
=
'
error
'
|
'
success
'
|
'
warning
'
|
'
debug
'
|
'
info
'
;
type
Data
=
DataElement
|
DataElement
[];
type
DataElement
=
Record
<
string
,
unknown
>
|
string
|
null
;
// eslint-disable-next-line import/no-default-export
export
default
class
Logger
{
private
context
:
Context
;
...
...
@@ -38,7 +41,7 @@ export default class Logger {
}
@
bindThis
private
log
(
level
:
Level
,
message
:
string
,
data
?:
Record
<
string
,
any
>
|
null
,
important
=
false
,
subContexts
:
Context
[]
=
[]):
void
{
private
log
(
level
:
Level
,
message
:
string
,
data
?:
Data
,
important
=
false
,
subContexts
:
Context
[]
=
[]):
void
{
if
(
envOption
.
quiet
)
return
;
if
(
this
.
parentLogger
)
{
...
...
@@ -68,17 +71,23 @@ export default class Logger {
if
(
envOption
.
withLogTime
)
log
=
chalk
.
gray
(
time
)
+
'
'
+
log
;
const
args
:
unknown
[]
=
[
important
?
chalk
.
bold
(
log
)
:
log
];
if
(
data
!=
null
)
{
if
(
Array
.
isArray
(
data
))
{
for
(
const
d
of
data
)
{
if
(
d
!=
null
)
{
args
.
push
(
d
);
}
}
}
else
if
(
data
!=
null
)
{
args
.
push
(
data
);
}
console
.
log
(...
args
);
}
@
bindThis
public
error
(
x
:
string
|
Error
,
data
?:
Record
<
string
,
any
>
|
null
,
important
=
false
):
void
{
// 実行を継続できない状況で使う
public
error
(
x
:
string
|
Error
,
data
?:
Data
,
important
=
false
):
void
{
// 実行を継続できない状況で使う
if
(
x
instanceof
Error
)
{
data
=
data
?
?
{}
;
data
.
e
=
x
;
data
=
data
?
(
Array
.
isArray
(
data
)
?
data
:
[
data
])
:
[]
;
data
.
unshift
({
e
:
x
})
;
this
.
log
(
'
error
'
,
x
.
toString
(),
data
,
important
);
}
else
if
(
typeof
x
===
'
object
'
)
{
this
.
log
(
'
error
'
,
`
${(
x
as
any
).
message
??
(
x
as
any
).
name
??
x
}
`
,
data
,
important
);
...
...
@@ -88,24 +97,24 @@ export default class Logger {
}
@
bindThis
public
warn
(
message
:
string
,
data
?:
Record
<
string
,
any
>
|
null
,
important
=
false
):
void
{
// 実行を継続できるが改善すべき状況で使う
public
warn
(
message
:
string
,
data
?:
Data
,
important
=
false
):
void
{
// 実行を継続できるが改善すべき状況で使う
this
.
log
(
'
warning
'
,
message
,
data
,
important
);
}
@
bindThis
public
succ
(
message
:
string
,
data
?:
Record
<
string
,
any
>
|
null
,
important
=
false
):
void
{
// 何かに成功した状況で使う
public
succ
(
message
:
string
,
data
?:
Data
,
important
=
false
):
void
{
// 何かに成功した状況で使う
this
.
log
(
'
success
'
,
message
,
data
,
important
);
}
@
bindThis
public
debug
(
message
:
string
,
data
?:
Record
<
string
,
any
>
|
null
,
important
=
false
):
void
{
// デバッグ用に使う(開発者に必要だが利用者に不要な情報)
public
debug
(
message
:
string
,
data
?:
Data
,
important
=
false
):
void
{
// デバッグ用に使う(開発者に必要だが利用者に不要な情報)
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
||
envOption
.
verbose
)
{
this
.
log
(
'
debug
'
,
message
,
data
,
important
);
}
}
@
bindThis
public
info
(
message
:
string
,
data
?:
Record
<
string
,
any
>
|
null
,
important
=
false
):
void
{
// それ以外
public
info
(
message
:
string
,
data
?:
Data
,
important
=
false
):
void
{
// それ以外
this
.
log
(
'
info
'
,
message
,
data
,
important
);
}
}
This diff is collapsed.
Click to expand it.
packages/backend/src/queue/QueueProcessorService.ts
+
1
−
1
View file @
abb2c375
...
...
@@ -349,7 +349,7 @@ export class QueueProcessorService implements OnApplicationShutdown {
});
}
})
.
on
(
'
error
'
,
(
err
:
Error
)
=>
logger
.
error
(
`error
${
err
.
name
}
:
${
err
.
message
}
`
,
{
e
:
renderError
(
err
)
}
))
.
on
(
'
error
'
,
(
err
:
Error
)
=>
logger
.
error
(
'
inbox error:
'
,
renderError
(
err
)))
.
on
(
'
stalled
'
,
(
jobId
)
=>
logger
.
warn
(
`stalled id=
${
jobId
}
`
));
}
//#endregion
...
...
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