Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
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
Dima Krasner
Sharkey
Commits
3be89e97
Unverified
Commit
3be89e97
authored
6 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
Better logging
parent
4275af23
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/index.ts
+9
-7
9 additions, 7 deletions
src/index.ts
src/misc/logger.ts
+5
-5
5 additions, 5 deletions
src/misc/logger.ts
with
14 additions
and
12 deletions
src/index.ts
+
9
−
7
View file @
3be89e97
...
...
@@ -70,6 +70,8 @@ async function masterMain() {
//#endregion
}
console
.
log
(
chalk
`
${
os
.
hostname
()}
{gray (PID:
${
process
.
pid
.
toString
()}
)}`
);
bootLogger
.
info
(
'
Welcome to Misskey!
'
);
bootLogger
.
info
(
`Misskey v
${
pkg
.
version
}
`
,
true
);
bootLogger
.
info
(
'
Misskey is maintained by @syuilo, @AyaMorisawa, @mei23 and @acid-chicken.
'
);
...
...
@@ -118,14 +120,14 @@ async function isPortAvailable(port: number): Promise<boolean> {
async
function
showMachine
()
{
const
logger
=
bootLogger
.
createSubLogger
(
'
machine
'
);
logger
.
info
(
`Hostname:
${
os
.
hostname
()}
`
);
logger
.
info
(
`Platform:
${
process
.
platform
}
`
);
logger
.
info
(
`Architecture:
${
process
.
arch
}
`
);
logger
.
info
(
`CPU:
${
os
.
cpus
().
length
}
core`
);
logger
.
debug
(
`Hostname:
${
os
.
hostname
()}
`
);
logger
.
debug
(
`Platform:
${
process
.
platform
}
`
);
logger
.
debug
(
`Architecture:
${
process
.
arch
}
`
);
logger
.
debug
(
`CPU:
${
os
.
cpus
().
length
}
core`
);
const
mem
=
await
sysUtils
.
mem
();
const
totalmem
=
(
mem
.
total
/
1024
/
1024
/
1024
).
toFixed
(
1
);
const
availmem
=
(
mem
.
available
/
1024
/
1024
/
1024
).
toFixed
(
1
);
logger
.
info
(
`MEM:
${
totalmem
}
GB (available:
${
availmem
}
GB)`
);
logger
.
debug
(
`MEM:
${
totalmem
}
GB (available:
${
availmem
}
GB)`
);
}
function
showEnvironment
():
void
{
...
...
@@ -257,12 +259,12 @@ function spawnWorker(): Promise<void> {
// Listen new workers
cluster
.
on
(
'
fork
'
,
worker
=>
{
clusterLog
.
info
(
`Process forked: [
${
worker
.
id
}
]`
);
clusterLog
.
debug
(
`Process forked: [
${
worker
.
id
}
]`
);
});
// Listen online workers
cluster
.
on
(
'
online
'
,
worker
=>
{
clusterLog
.
succ
(
`Process is now online: [
${
worker
.
id
}
]`
);
clusterLog
.
debug
(
`Process is now online: [
${
worker
.
id
}
]`
);
});
// Listen for dying workers
...
...
This diff is collapsed.
Click to expand it.
src/misc/logger.ts
+
5
−
5
View file @
3be89e97
...
...
@@ -45,13 +45,13 @@ export default class Logger {
this
.
log
(
important
?
chalk
.
bgGreen
.
white
(
'
DONE
'
)
:
chalk
.
green
(
'
DONE
'
),
chalk
.
green
(
message
),
important
);
}
public
info
(
message
:
string
,
important
=
false
):
void
{
// それ以外
this
.
log
(
chalk
.
blue
(
'
INFO
'
),
message
,
important
);
}
public
debug
(
message
:
string
,
important
=
false
):
void
{
// デバッグ用に使う
public
debug
(
message
:
string
,
important
=
false
):
void
{
// デバッグ用に使う(開発者にとっては必要だが利用者にとっては不要な情報)
if
(
process
.
env
.
NODE_ENV
!=
'
production
'
)
{
this
.
log
(
chalk
.
gray
(
'
VERB
'
),
chalk
.
gray
(
message
),
important
);
}
}
public
info
(
message
:
string
,
important
=
false
):
void
{
// それ以外
this
.
log
(
chalk
.
blue
(
'
INFO
'
),
message
,
important
);
}
}
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