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
05baa895
Unverified
Commit
05baa895
authored
6 years ago
by
syuilo
Browse files
Options
Downloads
Patches
Plain Diff
Refactoring of logger
parent
80aa4537
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
+7
-7
7 additions, 7 deletions
src/index.ts
src/misc/logger.ts
+7
-2
7 additions, 2 deletions
src/misc/logger.ts
with
14 additions
and
9 deletions
src/index.ts
+
7
−
7
View file @
05baa895
...
...
@@ -26,8 +26,8 @@ import { lessThan } from './prelude/array';
import
*
as
pkg
from
'
../package.json
'
;
const
logger
=
new
Logger
(
'
core
'
);
const
bootLogger
=
new
Logger
(
'
boot
'
,
logger
);
const
clusterLog
=
new
Logger
(
'
cluster
'
,
logger
);
const
bootLogger
=
logger
.
createSub
Logger
(
'
boot
'
);
const
clusterLog
=
logger
.
createSub
Logger
(
'
cluster
'
);
const
ev
=
new
Xev
();
if
(
process
.
env
.
NODE_ENV
!=
'
production
'
&&
process
.
env
.
DEBUG
==
null
)
{
...
...
@@ -116,7 +116,7 @@ async function isPortAvailable(port: number): Promise<boolean> {
}
async
function
showMachine
()
{
const
logger
=
new
Logger
(
'
M
achine
'
,
bootLogger
);
const
logger
=
bootLogger
.
createSub
Logger
(
'
m
achine
'
);
logger
.
info
(
`Hostname:
${
os
.
hostname
()}
`
);
logger
.
info
(
`Platform:
${
process
.
platform
}
`
);
logger
.
info
(
`Architecture:
${
process
.
arch
}
`
);
...
...
@@ -129,7 +129,7 @@ async function showMachine() {
function
showEnvironment
():
void
{
const
env
=
process
.
env
.
NODE_ENV
;
const
logger
=
new
Logger
(
'
Env
'
,
bootLogger
);
const
logger
=
boot
Logger
.
createSubLogger
(
'
env
'
);
logger
.
info
(
typeof
env
==
'
undefined
'
?
'
NODE_ENV is not set
'
:
`NODE_ENV:
${
env
}
`
);
if
(
env
!==
'
production
'
)
{
...
...
@@ -147,7 +147,7 @@ async function init(): Promise<Config> {
bootLogger
.
info
(
'
Welcome to Misskey!
'
);
bootLogger
.
info
(
`<<< Misskey v
${
pkg
.
version
}
>>>`
);
const
nodejsLogger
=
new
Logger
(
'
N
odejs
'
,
bootLogger
);
const
nodejsLogger
=
bootLogger
.
createSub
Logger
(
'
n
odejs
'
);
nodejsLogger
.
info
(
`Version
${
runningNodejsVersion
.
join
(
'
.
'
)}
`
);
...
...
@@ -159,7 +159,7 @@ async function init(): Promise<Config> {
await
showMachine
();
showEnvironment
();
const
configLogger
=
new
Logger
(
'
C
onfig
'
,
bootLogger
);
const
configLogger
=
bootLogger
.
createSub
Logger
(
'
c
onfig
'
);
let
config
;
try
{
...
...
@@ -202,7 +202,7 @@ async function init(): Promise<Config> {
const
requiredMongoDBVersion
=
[
3
,
6
];
function
checkMongoDB
(
config
:
Config
)
{
const
mongoDBLogger
=
new
Logger
(
'
MongoDB
'
,
boot
Logger
);
const
mongoDBLogger
=
boot
Logger
.
createSub
Logger
(
'
db
'
);
const
u
=
config
.
mongodb
.
user
?
encodeURIComponent
(
config
.
mongodb
.
user
)
:
null
;
const
p
=
config
.
mongodb
.
pass
?
encodeURIComponent
(
config
.
mongodb
.
pass
)
:
null
;
const
uri
=
`mongodb://
${
u
&&
p
?
`
${
u
}
:****@`
:
''
}${
config
.
mongodb
.
host
}
:
${
config
.
mongodb
.
port
}
/
${
config
.
mongodb
.
db
}
`
;
...
...
This diff is collapsed.
Click to expand it.
src/misc/logger.ts
+
7
−
2
View file @
05baa895
...
...
@@ -5,9 +5,14 @@ export default class Logger {
private
domain
:
string
;
private
parentLogger
:
Logger
;
constructor
(
domain
:
string
,
parentLogger
?:
Logger
)
{
constructor
(
domain
:
string
)
{
this
.
domain
=
domain
;
this
.
parentLogger
=
parentLogger
;
}
public
createSubLogger
(
domain
:
string
):
Logger
{
const
logger
=
new
Logger
(
domain
);
logger
.
parentLogger
=
this
;
return
logger
;
}
public
log
(
level
:
string
,
message
:
string
,
important
=
false
):
void
{
...
...
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