Translate log messages

This commit is contained in:
Douglas Barone 2021-01-18 16:57:04 -04:00
parent f47c2f10a0
commit 87beeeb0ee
8 changed files with 24 additions and 23 deletions

View File

@ -40,7 +40,7 @@ class ResetToken {
logInfo({ logInfo({
tags: ['token', 'user'], tags: ['token', 'user'],
message: `User ${creatorUsername} created a reset-token for user ${username}` message: `Usuário ${creatorUsername} criou um token para o aluno ${username}`
}) })
return { return {

View File

@ -286,20 +286,20 @@ class User {
try { try {
logInfo({ logInfo({
tags: ['user', 'login'], tags: ['user', 'login'],
message: `User ${username} is trying to login` message: `Usuáio ${username} está tentando logar`
}) })
await ad.authenticate(`ifms\\${username}`, password) await ad.authenticate(`ifms\\${username}`, password)
logSuccess({ logSuccess({
tags: ['user', 'login'], tags: ['user', 'login'],
message: `User ${username} logged successfully` message: `Usuário ${username} logou com sucesso`
}) })
} catch (err) { } catch (err) {
if (await ad.checkBinding()) { if (await ad.checkBinding()) {
logWarning({ logWarning({
tags: ['user', 'login', 'password'], tags: ['user', 'login', 'password'],
message: `User ${username} tried to login but failed` message: `Usuário ${username} tentou logar, mas falhou`
}) })
throw new Error('Usuário ou senha inválidos.') throw new Error('Usuário ou senha inválidos.')
} else { } else {
@ -351,7 +351,8 @@ class User {
if (this.working) { if (this.working) {
logWarning({ logWarning({
tags: ['user', 'AD'], tags: ['user', 'AD'],
message: 'User import aborted: already working' message:
'Importação de usuários abortada! Já há uma importação em andamento.'
}) })
return 0 return 0
} }
@ -361,7 +362,7 @@ class User {
try { try {
logInfo({ logInfo({
tags: ['user', 'AD'], tags: ['user', 'AD'],
message: 'Getting users from Active Directory.' message: 'Obtendo usuários do Active Directory.'
}) })
const allAdUsers = await ad.findUsers({ const allAdUsers = await ad.findUsers({
@ -371,7 +372,7 @@ class User {
logInfo({ logInfo({
tags: ['user', 'AD'], tags: ['user', 'AD'],
message: 'Importing users into database' message: 'Importando usuários para o Banco de Dados local'
}) })
await Promise.all( await Promise.all(

View File

@ -6,20 +6,20 @@ import { deleteOldLogs, log, logInfo, logSuccess } from './lib/logger'
logInfo({ logInfo({
tags: ['cron'], tags: ['cron'],
message: 'Scheduling tasks...' message: 'Agendando tarefas...'
}) })
cron.schedule('0 0 0 * * *', async () => { cron.schedule('0 0 0 * * *', async () => {
logInfo({ logInfo({
tags: ['cron', 'user'], tags: ['cron', 'user'],
message: `User.importAllUsers started` message: `User.importAllUsers iniciado`
}) })
const users = await User.importAllUsers() const users = await User.importAllUsers()
logInfo({ logInfo({
tags: ['cron', 'user'], tags: ['cron', 'user'],
message: `User.importAllUsers imported ${users} users` message: `User.importAllUsers importou ${users} usuários`
}) })
}) })
@ -27,7 +27,7 @@ cron.schedule('0 0 0 * * *', async () => {
await oui.update() await oui.update()
logSuccess({ logSuccess({
tags: ['cron', 'oui'], tags: ['cron', 'oui'],
message: `OUI list updated` message: `Lista de OUIs atualizada`
}) })
}) })

View File

@ -48,7 +48,7 @@ const replacePassword = (username, newPassword) => {
client.unbind(() => { client.unbind(() => {
logError({ logError({
tags: ['user', 'replacePassword'], tags: ['user', 'replacePassword'],
message: 'Error raplacing password', message: 'Erro ao sobrescrever senha.',
data: err data: err
}) })
}) })
@ -57,7 +57,7 @@ const replacePassword = (username, newPassword) => {
User.upsertUser(username) User.upsertUser(username)
logSuccess({ logSuccess({
tags: ['user', 'replacePassword'], tags: ['user', 'replacePassword'],
message: `Password updated for user ${username}`, message: `Senha atualizada para o usuário ${username}`,
data: result data: result
}) })
resolve('Senha alterada com sucesso!') resolve('Senha alterada com sucesso!')

View File

@ -83,7 +83,7 @@ async function updateUserIdMappings() {
logSuccess({ logSuccess({
tags: ['user-id', 'paloalto'], tags: ['user-id', 'paloalto'],
message: `Updated ${devices.length} user-id mappings on ${ message: `Atualizado ${devices.length} mapeamentos de user-id no ${
pAHost.description || pAHost.cidr pAHost.description || pAHost.cidr
}`, }`,
data: devices data: devices
@ -93,7 +93,7 @@ async function updateUserIdMappings() {
} catch (e) { } catch (e) {
logError({ logError({
tags: ['paloalto', 'user-id'], tags: ['paloalto', 'user-id'],
message: `Error updating user-id mappings: ${e.message}`, message: `Erro atualizando user-id mappings: ${e.message}`,
data: e data: e
}) })

View File

@ -116,14 +116,14 @@ async function updateDB(onlineDevices) {
} catch (e) { } catch (e) {
logError({ logError({
tags: ['wifiDevices'], tags: ['wifiDevices'],
message: `Error trying to upsert device with mac "${device.mac}". It has an user, but not in AD. And fails anyway...`, message: `Erro tentando adicionar o dispositivo "${device.mac}". Ele tinha um usuário fora do AD que foi ignorado, mas falhou mesmo assim`,
data: { error: e, device } data: { error: e, device }
}) })
} }
else else
logError({ logError({
tags: ['wifiDevices'], tags: ['wifiDevices'],
message: `Error trying to upsert device with mac "${device.mac}"`, message: `Erro tentando adicionar o dispositivo "${device.mac}"`,
data: { error: e, device } data: { error: e, device }
}) })
} }
@ -148,7 +148,7 @@ async function updateDevicesInfo() {
logSuccess({ logSuccess({
tags: ['wifiDevices'], tags: ['wifiDevices'],
message: `Updated ${onlineDevices.length} devices`, message: `Atualizados ${onlineDevices.length} dispositivos`,
data: onlineDevices data: onlineDevices
}) })
@ -156,7 +156,7 @@ async function updateDevicesInfo() {
} catch (e) { } catch (e) {
logError({ logError({
tags: ['wifiDevices'], tags: ['wifiDevices'],
message: `Error updating Wi-Fi devices: ${e.message}`, message: `Erro atualizando dispositivos Wi-Fi: ${e.message}`,
data: e data: e
}) })

View File

@ -19,7 +19,7 @@ const Mutation = {
async replacePassword(_, { data }, { auth }) { async replacePassword(_, { data }, { auth }) {
logInfo({ logInfo({
tags: ['replacePassword', 'user'], tags: ['replacePassword', 'user'],
message: `User ${auth.sAMAccountName} is replacing the password for user ${data.username}` message: `Usuário ${auth.sAMAccountName} está trocando a senha do usuário ${data.username}`
}) })
return replacePassword(data.username, data.newPassword) return replacePassword(data.username, data.newPassword)

View File

@ -8,7 +8,7 @@ async function updateDevicesTask() {
try { try {
logInfo({ logInfo({
tags: ['task', 'wifiDevices'], tags: ['task', 'wifiDevices'],
message: 'updateDevicesTask started' message: 'updateDevicesTask iniciou'
}) })
const devicesQnt = await updateDevicesInfo() const devicesQnt = await updateDevicesInfo()
@ -19,7 +19,7 @@ async function updateDevicesTask() {
} catch (e) { } catch (e) {
logError({ logError({
tags: ['task', 'wifiDevices', 'user-id'], tags: ['task', 'wifiDevices', 'user-id'],
message: `Error executing task.`, message: `Erro executando tarefa.`,
data: e data: e
}) })
} finally { } finally {
@ -32,7 +32,7 @@ async function updateDevicesTask() {
function runTasks() { function runTasks() {
logInfo({ logInfo({
tags: ['task'], tags: ['task'],
message: `Running tasks with ${SLEEP_IN_MILLISECONDS}ms sleeps.` message: `Rodando tarefas com ${SLEEP_IN_MILLISECONDS}ms de intervalo.`
}) })
updateDevicesTask() updateDevicesTask()