Skip to content

Commit

Permalink
update manager because of base class changes
Browse files Browse the repository at this point in the history
  • Loading branch information
marcuspoehls committed Oct 19, 2023
1 parent 76381b6 commit 75b305d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
30 changes: 1 addition & 29 deletions packages/logging/src/log-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ import { Manager } from '@supercharge/manager'
import { ConsoleLogger } from './console-logger.js'
import { Application, Logger as LoggingContract, LoggingConfig } from '@supercharge/contracts'

export class LogManager extends Manager implements LoggingContract {
export class LogManager extends Manager<Application> implements LoggingContract {
/**
* Stores the logging config.
*/
private readonly options: LoggingConfig

/**
* Create a new logs manager instance.
*
* @param {Application} app
*/
constructor (app: Application, config: LoggingConfig) {
super(app)
Expand All @@ -23,80 +21,62 @@ export class LogManager extends Manager implements LoggingContract {

/**
* Log the given `message` at debug level.
*
* @param message
*/
debug (message: string, ...context: any[]): void {
this.driver().debug(message, ...context)
}

/**
* Log the given `message` at info level.
*
* @param message
*/
info (message: string, ...context: any[]): void {
this.driver().info(message, ...context)
}

/**
* Log the given `message` at notice level.
*
* @param message
*/
notice (message: string, ...context: any[]): void {
this.driver().notice(message, ...context)
}

/**
* Log the given `message` at warning level.
*
* @param message
*/
warning (message: string, ...context: any[]): void {
this.driver().warning(message, ...context)
}

/**
* Log the given `message` at error level.
*
* @param message
*/
error (message: string, ...context: any[]): void {
this.driver().error(message, ...context)
}

/**
* Log the given `message` at critical level.
*
* @param message
*/
critical (message: string, ...context: any[]): void {
this.driver().critical(message, ...context)
}

/**
* Log the given `message` at alert level.
*
* @param message
*/
alert (message: string, ...context: any[]): void {
this.driver().alert(message, ...context)
}

/**
* Log the given `message` at emergency level.
*
* @param message
*/
emergency (message: string, ...context: any[]): void {
this.driver().emergency(message, ...context)
}

/**
* Returns the default logging driver name.
*
* @returns {String}
*/
protected defaultDriver (): string {
return this.options.driver ?? 'console'
Expand All @@ -105,28 +85,20 @@ export class LogManager extends Manager implements LoggingContract {
/**
* Returns the driver instance. This method exists to retrieve
* IntelliSense because of the method’s specific return value.
*
* @param {String} name
*
* @returns {ViewEngine}
*/
override driver (name?: string): LoggingContract {
return super.driver(name)
}

/**
* Create a file logging driver.
*
* @returns {FileLogger}
*/
protected createFileDriver (): LoggingContract {
return new FileLogger(this.options.channels.file ?? {} as any)
}

/**
* Create a a console logging driver.
*
* @returns {Logger}
*/
protected createConsoleDriver (): LoggingContract {
return new ConsoleLogger(this.options.channels.console ?? { } as any)
Expand Down
6 changes: 3 additions & 3 deletions packages/view/src/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Manager } from '@supercharge/manager'
import { HandlebarsCompiler } from './engines/handlebars/index.js'
import { Application, ViewConfig, ViewEngine, ViewResponseConfig } from '@supercharge/contracts'

export class ViewManager extends Manager implements ViewEngine {
export class ViewManager extends Manager<Application> implements ViewEngine {
/**
* Stores the internal view configuration object.
*/
Expand All @@ -27,11 +27,11 @@ export class ViewManager extends Manager implements ViewEngine {
* Validate the view config.
*/
private validateConfig (): void {
this.ensureConfig('view', () => {
this.app.config().ensure('view', () => {
throw new Error('Missing view configuration file. Make sure the "config/view.ts" file exists.')
})

this.ensureConfig('view.driver')
this.app.config().ensure('view.driver')
}

/**
Expand Down

0 comments on commit 75b305d

Please sign in to comment.