Skip to content

Enhancing the LoggerService with prefix & file printing #18

@ThePawlow

Description

@ThePawlow

At this very moment, I don't understand the difference of logging something with the UtilService or LoggerService.

Suggestion

The LoggerService gets enhanced with being able to:

  • Set a prefix
  • Debug Level (0, 1, 2, 3)
  • Log only in Development and/or Production
  • Log to a file in certain directory

Example

enum ImportanceEnum {
	Info = 0,
	Warning = 1,
	Error = 2,
	CriticalError = 3
}

setup(logToFile: Path, logInProduction: boolean = false): void
log(prefix: string, text: string, level: ImportanceEnum): void

// Setup must be called first
this.loggerService.setup("./logs", false);

this.loggerService.log("[Vehicle Module]","Vehicle doesn't exist", ImportanceEnum.CriticalError);

// Which would generate the following
// Root Dir -> logs/15.06.2021
// (15.06.2021 14:01) [CriticalError] [Vehicle Module]: Vehicle doesn't exist

Final Words

This is a rough idea, feel free to discuss

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions