Skip to content

Commit 5b2b8a7

Browse files
committed
feat(gateway): add app logger
1 parent 8a79d68 commit 5b2b8a7

File tree

11 files changed

+64
-32
lines changed

11 files changed

+64
-32
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ Adoraríamos que você contribuísse com o projeto e ajudasse a torná-la ainda
77
- [Issues and Bugs](#issue)
88
- [Feature Requests](#feature)
99
- [Regras de codificação](#rules)
10+
1011
## <a name="coc"></a> Código de Conduta
1112

1213
Ajude-nos a manter a comunidade Speek aberta e inclusiva. Por favor, leia e siga nosso [Código de Conduta](CODE_OF_CONDUCT.md).
1314

14-
1515
## <a name="question"></a> Tem alguma dúvida ou problema?
1616

1717
Não abra issues para questões gerais de suporte relacionadas a tecnologia WebRTC, pois queremos manter as issues do GitHub para relatórios de bugs. Em vez disso você pode [iniciar uma discussão](https://github.com/guiseek/speek.video/discussions/new) com a comunidade speek.video. Caso não funcione, recomendamos o uso do [Stack Overflow](https://stackoverflow.com/questions/tagged/speek.video) para fazer perguntas relacionadas ao suporte. Ao criar uma nova pergunta no Stack Overflow, certifique-se de adicionar a `speek.video` tag.
@@ -194,6 +194,7 @@ A mensagem do commit deve ser estruturada da seguinte forma:
194194
195195
[rodapé opcional]
196196
```
197+
197198
---
198199

199200
O commit contém os seguintes elementos estruturais, para comunicar a intenção ao utilizador da sua biblioteca:
@@ -252,7 +253,6 @@ closes issue #12
252253

253254
As palavras-chaves "DEVE" ("MUST"), "NÃO DEVE" ("MUST NOT"), "OBRIGATÓRIO" ("REQUIRED"), "DEVERÁ" ("SHALL"), "NÃO DEVERÁ" ("SHALL NOT"), "PODEM" ("SHOULD"), "NÃO PODEM" ("SHOULD NOT"), "RECOMENDADO" ("RECOMMENDED"), "PODE" ("MAY") e "OPCIONAL" ("OPTIONAL"), nesse documento, devem ser interpretados como descrito na [RFC 2119](http://tools.ietf.org/html/rfc2119).
254255

255-
256256
1. A mensagem de commit DEVE ser prefixado com um tipo, que consiste em um substantivo, `feat`, `fix`, etc., seguido por um escopo OPCIONAL, e OBRIGATÓRIO terminar com dois-pontos e um espaço.
257257

258258
1. O tipo `feat` DEVE ser usado quando um commit adiciona um novo recurso ao seu aplicativo ou biblioteca.
@@ -277,7 +277,6 @@ As palavras-chaves "DEVE" ("MUST"), "NÃO DEVE" ("MUST NOT"), "OBRIGATÓRIO" ("R
277277

278278
1. Um `!` PODE ser acrescentado antes do `:` no prefixo tipo/escopo, para chamar a atenção para modificações que quebram a compatibilidade. `BREAKING CHANGE: description` também DEVE ser incluído no corpo ou no rodapé, junto com o `!` no prefixo.
279279

280-
281280
#### Porque utilizar Conventional Commits
282281

283282
- Criação automatizada de CHANGELOGs.
@@ -286,10 +285,8 @@ As palavras-chaves "DEVE" ("MUST"), "NÃO DEVE" ("MUST NOT"), "OBRIGATÓRIO" ("R
286285
- Disparar processos de build e deploy.
287286
- Facilitar a contribuição de outras pessoas em seus projetos, permitindo que eles explorem um histórico de commits mais estruturado.
288287

289-
290288
---
291289

292-
293290
## Nossa stack
294291

295292
<div style="display:flex; align-items: center">
@@ -341,12 +338,6 @@ As palavras-chaves "DEVE" ("MUST"), "NÃO DEVE" ("MUST NOT"), "OBRIGATÓRIO" ("R
341338
</div>
342339
</div>
343340

344-
345-
346-
347-
348-
349-
350341
<!-- # Todo
351342
352343
> ### **_Luiz_**
@@ -369,4 +360,3 @@ As palavras-chaves "DEVE" ("MUST"), "NÃO DEVE" ("MUST NOT"), "OBRIGATÓRIO" ("R
369360
370361
Poderia ser algo amigável como "Entre na nossa reunião do Peek por este link: ..."
371362
R: Mas sim, isso faz sentido tbm..
372-

ROADMAP.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# ROADMAP
2+
23
### @ToDo
34

45
Algumas tarefas no roadmap de curto prazo
@@ -59,4 +60,4 @@ Algumas tarefas no roadmap de curto prazo
5960
- [ ] SIP ([asterisk](https://wiki.asterisk.org/wiki/display/AST/Configuring+Asterisk+for+WebRTC+Clients))
6061

6162
- [ ] Chat em grupo
62-
<br>_até 10 peers (limitação de banda user)_ -->
63+
<br>_até 10 peers (limitação de banda user)_ -->

apps/gateway/src/app.logger.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { App } from './app.logger'
2+
3+
describe('App', () => {
4+
it('should create an instance', () => {
5+
expect(new App()).toBeTruthy()
6+
})
7+
})

apps/gateway/src/app.logger.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { environment } from './environments/environment'
2+
import { LoggerService, Logger } from '@nestjs/common'
3+
4+
export class AppLogger extends Logger implements LoggerService {
5+
context: string
6+
7+
setContext(context: string) {
8+
this.context = context
9+
}
10+
11+
log(message: any, context?: string) {
12+
super.log(message, context ? context : this.context)
13+
}
14+
error(message: any, trace?: string, context?: string) {
15+
super.error(message, context ? context : this.context)
16+
}
17+
warn(message: any, context?: string) {
18+
super.warn(message, context ? context : this.context)
19+
}
20+
debug(message: any, context?: string) {
21+
if (!environment.production) {
22+
super.debug(message, context ? context : this.context)
23+
}
24+
}
25+
verbose(message: any, context?: string) {
26+
super.verbose(message, context ? context : this.context)
27+
}
28+
}

apps/gateway/src/app.module.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { SignalingModule } from './signaling/signaling.module'
22
import { AuthModule } from './auth/auth.module'
33
import { Module } from '@nestjs/common'
4+
import { AppLogger } from './app.logger'
45

56
@Module({
67
imports: [SignalingModule, AuthModule],
78
controllers: [],
8-
providers: [],
9+
providers: [AppLogger],
910
})
1011
export class AppModule {}

apps/gateway/src/main.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { Logger } from '@nestjs/common'
77
import { NestFactory } from '@nestjs/core'
88
import { readFileSync } from 'fs'
9+
import { AppLogger } from './app.logger'
910

1011
import { AppModule } from './app.module'
1112
// import { environment } from './environments/environment'
@@ -17,7 +18,9 @@ import { AppModule } from './app.module'
1718

1819
async function bootstrap() {
1920
// const httpsOptions = environment.certificate ? certificates : {}
20-
const app = await NestFactory.create(AppModule)
21+
const app = await NestFactory.create(AppModule, {
22+
logger: new AppLogger(),
23+
})
2124
const globalPrefix = 'gateway'
2225
app.setGlobalPrefix(globalPrefix)
2326
const port = process.env.PORT || 3333

apps/gateway/src/signaling/signaling.gateway.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { SpeekAction, SpeekPayload } from '@speek/core/entity'
1111
import { Server, Socket } from 'socket.io'
1212
import { UseGuards } from '@nestjs/common'
1313
import { SignalingGuard } from './signaling.guard'
14+
import { AppLogger } from '../app.logger'
1415

1516
@WebSocketGateway()
1617
export class SignalingGateway
@@ -20,14 +21,17 @@ export class SignalingGateway
2021

2122
users = new Map<string, string>()
2223

24+
constructor(readonly logger: AppLogger) {
25+
logger.setContext('Signaling')
26+
}
27+
2328
@UseGuards(SignalingGuard)
2429
@SubscribeMessage(SpeekAction.KnockKnock)
2530
knockKnock(
2631
@ConnectedSocket() contact: Socket,
2732
@MessageBody() payload: SpeekPayload
2833
) {
29-
console.log(payload)
30-
34+
this.logger.debug(payload, SpeekAction.KnockKnock)
3135
const room = this._room(payload)
3236
if (room.length >= 0 && room.length < 2) {
3337
contact.emit(SpeekAction.Available, true)
@@ -42,7 +46,7 @@ export class SignalingGateway
4246
@ConnectedSocket() contact: Socket,
4347
@MessageBody() payload: SpeekPayload
4448
) {
45-
console.log(payload)
49+
this.logger.debug(payload, SpeekAction.CreateOrJoin)
4650
if (!this.users.has(contact.id)) {
4751
this.users.set(contact.id, payload.sender)
4852
}
@@ -64,6 +68,7 @@ export class SignalingGateway
6468
@ConnectedSocket() contact: Socket,
6569
@MessageBody() payload: SpeekPayload
6670
) {
71+
this.logger.debug(payload, SpeekAction.Offer)
6772
const room = contact.to(payload.code)
6873
room.broadcast.emit(SpeekAction.Offer, payload)
6974
}
@@ -74,6 +79,7 @@ export class SignalingGateway
7479
@ConnectedSocket() contact: Socket,
7580
@MessageBody() payload: SpeekPayload
7681
) {
82+
this.logger.debug(payload, SpeekAction.Screen)
7783
const room = contact.to(payload.code)
7884
room.broadcast.emit(SpeekAction.Screen, payload)
7985
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Module } from '@nestjs/common'
2+
import { AppLogger } from '../app.logger'
23
import { SignalingGateway } from './signaling.gateway'
34

45
@Module({
5-
providers: [SignalingGateway],
6+
providers: [AppLogger, SignalingGateway],
67
})
78
export class SignalingModule {}

apps/webapp/src/index.html

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@
1616
<!-- Open Graph / Facebook -->
1717
<meta property="og:type" content="website" />
1818
<meta property="og:url" content="https://speek.video/" />
19-
<meta
20-
property="og:title"
21-
content="Speek - Simples e seguro"
22-
/>
19+
<meta property="og:title" content="Speek - Simples e seguro" />
2320
<meta
2421
property="og:description"
2522
content="Crie um link para conversar e pronto. Sua ligação funciona pessoa pra pessoa, sem servidores, sem persistência, direto ao ponto."
@@ -29,18 +26,15 @@
2926
<!-- Twitter -->
3027
<meta property="twitter:card" content="summary_large_image" />
3128
<meta property="twitter:url" content="https://speek.video/" />
32-
<meta
33-
property="twitter:title"
34-
content="Speek - Simples e seguro"
35-
/>
29+
<meta property="twitter:title" content="Speek - Simples e seguro" />
3630
<meta
3731
property="twitter:description"
3832
content="Crie um link para conversar e pronto. Sua ligação funciona pessoa pra pessoa, sem servidores, sem persistência, direto ao ponto."
3933
/>
4034
<meta property="twitter:image" content="/assets/images/speek.svg" />
4135

4236
<link rel="icon" type="image/x-icon" href="/assets/icons/speek-7.png" />
43-
<link rel="apple-touch-icon" href="/assets/icons/speek-2.png">
37+
<link rel="apple-touch-icon" href="/assets/icons/speek-2.png" />
4438

4539
<link rel="preconnect" href="https://fonts.gstatic.com" />
4640
<link

apps/webapp/src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ const p: WithContext<WebApplication> = {
99
'@type': 'WebApplication',
1010
name: 'Speek - Simples e seguro',
1111
about: 'Crie um link para conversar e pronto.',
12-
description: 'Sua ligação funciona pessoa pra pessoa, sem servidores, sem persistência, direto ao ponto.',
12+
description:
13+
'Sua ligação funciona pessoa pra pessoa, sem servidores, sem persistência, direto ao ponto.',
1314
additionalType: 'Liberdade em áudio e vídeo',
14-
url: 'https://speek.video'
15+
url: 'https://speek.video',
1516
}
1617

1718
if (environment.production) {

0 commit comments

Comments
 (0)