Skip to content

Commit f6bbe7d

Browse files
fix: Use logger
1 parent 31f0015 commit f6bbe7d

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/Forum/Forum.router.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { server } from 'decentraland-server'
2+
import { ILoggerComponent } from '@well-known-components/interfaces'
23
import { Router } from '../common/Router'
34
import { HTTPError, STATUS_CODES } from '../common/HTTPError'
45
import { getValidator } from '../utils/validator'
@@ -16,6 +17,7 @@ import { MAX_FORUM_ITEMS } from '../Item/utils'
1617
import { Item } from '../Item'
1718
import { Bridge } from '../ethereum/api/Bridge'
1819
import { OwnableModel } from '../Ownable'
20+
import { ExpressApp } from '../common/ExpressApp'
1921
import { createPost } from './client'
2022
import { ForumService } from './Forum.service'
2123
import { ForumPost, forumPostSchema } from './Forum.types'
@@ -25,6 +27,12 @@ const validator = getValidator()
2527
export class ForumRouter extends Router {
2628
public service = new ForumService()
2729
public collectionService = new CollectionService()
30+
private logger: ILoggerComponent.ILogger
31+
32+
constructor(router: ExpressApp, logger: ILoggerComponent) {
33+
super(router)
34+
this.logger = logger.getLogger('ForumRouter')
35+
}
2836

2937
private modelAuthorizationCheck = (
3038
_: OwnableModel,
@@ -68,9 +76,10 @@ export class ForumRouter extends Router {
6876
validate(forumPostJSON)
6977

7078
if (validate.errors) {
71-
console.error(
72-
`Error trying to create the forum post for ${collectionId}, invalid schema`,
73-
validate.errors
79+
this.logger.error(
80+
`Error trying to create the forum post for ${collectionId}, invalid schema: ${JSON.stringify(
81+
validate.errors
82+
)}`
7483
)
7584
throw new HTTPError('Invalid schema', validate.errors)
7685
}
@@ -79,7 +88,7 @@ export class ForumRouter extends Router {
7988
const collection = await Collection.findOne(collectionId)
8089

8190
if (collection.forum_link) {
82-
console.error(
91+
this.logger.error(
8392
`Error trying to create the forum post for ${collectionId}, forum post already exists`
8493
)
8594
throw new HTTPError('Forum post already exists', { id: collectionId })
@@ -106,9 +115,10 @@ export class ForumRouter extends Router {
106115
return link
107116
}
108117
} catch (error) {
109-
console.error(
110-
`Error trying to create the forum post for ${collectionId}`,
111-
isErrorWithMessage(error) ? error.message : 'Unknown'
118+
this.logger.error(
119+
`Error trying to create the forum post for ${collectionId}: ${
120+
isErrorWithMessage(error) ? error.message : 'Unknown'
121+
}`
112122
)
113123
throw new HTTPError(
114124
'Error creating forum post',

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ new CurationRouter(app).mount()
5252
new CommitteeRouter(app).mount()
5353
new ThirdPartyRouter(app).mount()
5454
new RarityRouter(app).mount()
55-
new ForumRouter(app).mount()
55+
new ForumRouter(app, logs).mount()
5656
new ManifestRouter(app).mount()
5757
new DeploymentRouter(app).mount()
5858
new S3Router(app).mount()

0 commit comments

Comments
 (0)