Skip to content

Commit

Permalink
Merge pull request #74 from AthennaIO/develop
Browse files Browse the repository at this point in the history
Update deps
  • Loading branch information
jlenon7 authored Sep 7, 2023
2 parents 3a4f16d + f4c6e39 commit 2846eca
Show file tree
Hide file tree
Showing 36 changed files with 225 additions and 225 deletions.
6 changes: 3 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ build
*.js
*.d.ts
*.js.map
!tests/stubs/**/*.js
!tests/stubs/**/*.d.ts
!tests/stubs/**/*.js.map
!tests/fixtures/**/*.js
!tests/fixtures/**/*.d.ts
!tests/fixtures/**/*.js.map

# IDE
.idea
Expand Down
268 changes: 134 additions & 134 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@athenna/logger",
"version": "4.2.0",
"version": "4.3.0",
"description": "The Athenna logging solution. Log in stdout, files and buckets.",
"license": "MIT",
"author": "João Lenon <lenon@athenna.io>",
Expand Down Expand Up @@ -40,9 +40,9 @@
"types": "./src/index.d.ts",
"exports": {
".": "./src/index.js",
"./providers/LoggerProvider": "./src/providers/LoggerProvider.js",
"./types": "./src/types/index.js",
"./package.json": "./package.json"
"./package.json": "./package.json",
"./providers/LoggerProvider": "./src/providers/LoggerProvider.js"
},
"imports": {
"#bin/*": "./bin/*.js",
Expand All @@ -59,10 +59,10 @@
"cls-rtracer": "^2.6.3"
},
"devDependencies": {
"@athenna/common": "^4.4.0",
"@athenna/config": "^4.3.0",
"@athenna/ioc": "^4.1.0",
"@athenna/test": "^4.3.0",
"@athenna/common": "^4.10.1",
"@athenna/config": "^4.4.0",
"@athenna/ioc": "^4.2.0",
"@athenna/test": "^4.5.0",
"@typescript-eslint/eslint-plugin": "^5.56.0",
"@typescript-eslint/parser": "^5.56.0",
"c8": "^7.12.0",
Expand Down Expand Up @@ -119,7 +119,7 @@
},
"prettier": {
"singleQuote": true,
"trailingComma": "all",
"trailingComma": "none",
"arrowParens": "avoid",
"endOfLine": "lf",
"semi": false,
Expand Down
18 changes: 9 additions & 9 deletions src/constants/VanillaChannels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,42 @@
export const VANILLA_CHANNELS = {
default: {
driver: 'stack',
channels: ['application'],
channels: ['application']
},
stack: {
driver: 'stack',
channels: ['application'],
channels: ['application']
},
discard: {
driver: 'null',
driver: 'null'
},
file: {
driver: 'file',
level: 'trace',
filePath: Path.logs('athenna.log'),

formatter: 'simple',
formatterConfig: {},
formatterConfig: {}
},
console: {
level: 'trace',
formatter: 'cli',
driver: 'console',
driver: 'console'
},
request: {
level: 'trace',
formatter: 'request',
driver: 'console',
driver: 'console'
},
exception: {
level: 'trace',
formatter: 'none',
driver: 'console',
streamType: 'stderr',
streamType: 'stderr'
},
application: {
level: 'trace',
driver: 'console',
formatter: 'simple',
},
formatter: 'simple'
}
}
2 changes: 1 addition & 1 deletion src/drivers/ConsoleDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ConsoleDriver extends Driver {
debug(
'[%s] Transporting logs in %s stream.',
ConsoleDriver.name,
streamType,
streamType
)

return process[streamType].write(`${formatted}\n`)
Expand Down
4 changes: 2 additions & 2 deletions src/drivers/DiscordDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ export class DiscordDriver extends Driver {
'[%s] Transporting logs with username %s and in url %s.',
DiscordDriver.name,
this.configs.username,
this.configs.url,
this.configs.url
)

return HttpClient.builder(true).post(this.configs.url, {
username: this.configs.username,
content: formatted,
content: formatted
})
}
}
2 changes: 1 addition & 1 deletion src/drivers/Driver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export abstract class Driver {
'success',
'warn',
'error',
'fatal',
'fatal'
]

public constructor(configs: any = {}) {
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/FileDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class FileDriver extends Driver {
if (await File.exists(filePath)) {
debug(
'[%s] File already exist, appending the data to it.',
FileDriver.name,
FileDriver.name
)

return new File(filePath).append(buffer)
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/SlackDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class SlackDriver extends Driver {
debug(
'[%s] Transporting logs in url %s.',
SlackDriver.name,
this.configs.url,
this.configs.url
)

return HttpClient.builder(true).post(this.configs.url, { text: formatted })
Expand Down
6 changes: 3 additions & 3 deletions src/drivers/StackDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ export class StackDriver extends Driver {
debug(
'[%s] Transporting logs in channels: %s.',
StackDriver.name,
this.driverConfig.channels.join(', '),
this.driverConfig.channels.join(', ')
)

return Promise.all(
this.driverConfig.channels.map(c =>
DriverFactory.fabricate(c, configs).transport(level, message),
),
DriverFactory.fabricate(c, configs).transport(level, message)
)
)
}
}
6 changes: 3 additions & 3 deletions src/drivers/TelegramDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ export class TelegramDriver extends Driver {
TelegramDriver.name,
this.driverConfig.parseMode,
this.driverConfig.token,
this.driverConfig.chatId,
this.driverConfig.chatId
)

return new Telegraf(this.driverConfig.token).telegram.sendMessage(
this.driverConfig.chatId,
formatted,
{
parse_mode: this.driverConfig.parseMode,
},
parse_mode: this.driverConfig.parseMode
}
)
}
}
2 changes: 1 addition & 1 deletion src/exceptions/DriverExistException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class DriverExistException extends Exception {
status: 500,
code: 'E_EXIST_DRIVER',
message: `The driver ${driverName} already exists in DriverFactory.`,
help: `Available drivers are: ${availableDrivers}. The name ${driverName} is already in use inside DriverFactory. Try using a different name for your driver implementation.`,
help: `Available drivers are: ${availableDrivers}. The name ${driverName} is already in use inside DriverFactory. Try using a different name for your driver implementation.`
})
}
}
2 changes: 1 addition & 1 deletion src/exceptions/FormatterExistException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class FormatterExistException extends Exception {
status: 500,
code: 'E_EXIST_FORMATTER',
message: `The formatter ${formatterName} already exists in FormatterFactory.`,
help: `Available formatters are: ${availableFormatters}. The name ${formatterName} is already in use inside FormatterFactory. Try using a different name for your formatter implementation.`,
help: `Available formatters are: ${availableFormatters}. The name ${formatterName} is already in use inside FormatterFactory. Try using a different name for your formatter implementation.`
})
}
}
2 changes: 1 addition & 1 deletion src/exceptions/NotFoundDriverException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class NotFoundDriverException extends Exception {
status: 500,
code: 'E_NOT_FOUND',
message: `The driver ${driverName} has not been found.`,
help: `Available drivers are: ${availableDrivers}. Look into your config/logger.${Path.ext()} file if ${driverName} driver is implemented by logger. Or create ${driverName} driver implementation using DriverFactory.createDriver("${driverName}", ...) method.`,
help: `Available drivers are: ${availableDrivers}. Look into your config/logger.${Path.ext()} file if ${driverName} driver is implemented by logger. Or create ${driverName} driver implementation using DriverFactory.createDriver("${driverName}", ...) method.`
})
}
}
2 changes: 1 addition & 1 deletion src/exceptions/NotFoundFormatterException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class NotFoundFormatterException extends Exception {
status: 500,
code: 'E_NOT_FOUND',
message: `The formatter ${formatterName} has not been found.`,
help: `Available formatters are: ${availableDrivers}. Look into your config/logger file if ${formatterName} formatter is implemented by logger. Or create ${formatterName} formatter implementation using FormatterFactory.createFormatter("${formatterName}", ...) method.`,
help: `Available formatters are: ${availableDrivers}. Look into your config/logger file if ${formatterName} formatter is implemented by logger. Or create ${formatterName} formatter implementation using FormatterFactory.createFormatter("${formatterName}", ...) method.`
})
}
}
2 changes: 1 addition & 1 deletion src/exceptions/NotImplementedConfigException.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class NotImplementedConfigException extends Exception {
status: 500,
code: 'E_NOT_IMPLEMENTED_CONFIG_ERROR',
message: `Channel ${channelName} is not configured inside logging.channels object from config/logging.${Path.ext()} file.`,
help,
help
})
}
}
2 changes: 1 addition & 1 deletion src/factories/DriverFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class DriverFactory {
public static fabricateVanilla(configs: any = {}): Driver {
configs = Options.create(configs, {
driver: 'console',
formatter: 'none',
formatter: 'none'
})

if (!this.drivers.has(configs.driver)) {
Expand Down
2 changes: 1 addition & 1 deletion src/factories/FormatterFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class FormatterFactory {
*/
public static createFormatter(
name: string,
formatter: typeof Formatter,
formatter: typeof Formatter
): void {
if (this.formatters.has(name)) {
throw new FormatterExistException(name)
Expand Down
6 changes: 3 additions & 3 deletions src/formatters/Formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export abstract class Formatter {
minute: 'numeric',
second: 'numeric',
day: '2-digit',
month: '2-digit',
month: '2-digit'
}

return new Date(Date.now()).toLocaleString(undefined, localeStringOptions)
Expand Down Expand Up @@ -184,7 +184,7 @@ export abstract class Formatter {
success: '\u{2705}',
warn: '\u{26A0}',
error: '\u{274C}',
fatal: '\u{1F6D1}',
fatal: '\u{1F6D1}'
}

if (!levelEmojis[level.toLowerCase()]) {
Expand All @@ -207,7 +207,7 @@ export abstract class Formatter {
success: Color.success,
warn: Color.warn,
error: Color.error,
fatal: Color.fatal,
fatal: Color.fatal
}

if (!levelColors[levelLower]) {
Expand Down
2 changes: 1 addition & 1 deletion src/formatters/JsonFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class JsonFormatter extends Formatter {
time: Date.now(),
pid: this.pid(),
hostname: this.hostname(),
traceId: this.traceId(),
traceId: this.traceId()
}

if (Is.String(message)) {
Expand Down
4 changes: 2 additions & 2 deletions src/formatters/MessageFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ export class MessageFormatter extends Formatter {
public format(message: string): string {
return this.clean(
`${this.messageLevel()} - (${this.pid()}) - (${this.hostname()}): ${this.toString(
message,
)}`,
message
)}`
)
}
}
10 changes: 5 additions & 5 deletions src/formatters/RequestFormatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ export class RequestFormatter extends Formatter {
const status = ctx.status
const responseTimeMs = `${Math.round(ctx.responseTime)}ms`
const methodAndStatus = Color[ctx.request.method](
`[${ctx.request.method}::${ctx.status}]`,
`[${ctx.request.method}::${ctx.status}]`
)

if (!this.configs.asJson) {
return this.clean(
`${methodAndStatus} - [${ip}] - ${new Date().toISOString()} - ${
ctx.request.baseUrl
} ${responseTimeMs}`,
} ${responseTimeMs}`
)
}

Expand All @@ -40,7 +40,7 @@ export class RequestFormatter extends Formatter {
path: ctx.request.baseUrl,
createdAt: Date.now(),
traceId: this.traceId(),
data: ctx.data,
data: ctx.data
}

const request = {
Expand All @@ -49,12 +49,12 @@ export class RequestFormatter extends Formatter {
body: ctx.request.body,
params: ctx.request.params,
queries: ctx.request.queries,
headers: ctx.request.headers,
headers: ctx.request.headers
}

const response = {
body: ctx.body,
headers: ctx.headers,
headers: ctx.headers
}

return JSON.stringify({ request, response, metadata })
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/FactoryHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class FactoryHelper {
const formatter = object.formatter || defaultValue.formatter
const formatterConfig = Options.create(
object.formatterConfig,
defaultValue.formatterConfig,
defaultValue.formatterConfig
)

const driverConfig = Options.create(object, defaultValue)
Expand Down
4 changes: 2 additions & 2 deletions src/logger/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export class Logger {

return this.vanilla({
...VANILLA_CHANNELS[channel],
...configs,
...configs
})
}

Expand Down Expand Up @@ -165,7 +165,7 @@ export class Logger {
const message = Color.apply(...args)

const promises = this.drivers.map((driver: Driver) =>
driver.transport(level, message),
driver.transport(level, message)
)

return Promise.all(promises)
Expand Down
Loading

0 comments on commit 2846eca

Please sign in to comment.