Skip to content

Commit

Permalink
Logger changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vorlias committed Apr 21, 2022
1 parent 66eb3b6 commit ec82aa9
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rbxts/log",
"version": "0.6.2",
"version": "0.6.3",
"description": "Structured logging library for Roblox",
"main": "out/init.lua",
"scripts": {
Expand Down
6 changes: 3 additions & 3 deletions src/Configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ export class LogConfiguration {
}

public Create() {
this.logger._setSinks(this.sinks);
this.logger._setEnrichers(this.enrichers);
this.logger._setMinLogLevel(this.logLevel);
this.logger.SetSinks(this.sinks);
this.logger.SetEnrichers(this.enrichers);
this.logger.SetMinLogLevel(this.logLevel);
return this.logger;
}
}
11 changes: 7 additions & 4 deletions src/Logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,19 @@ export class Logger {
}

/** @internal */
public _setSinks(sinks: ReadonlyArray<ILogEventSink>) {
public SetSinks(sinks: ReadonlyArray<ILogEventSink>) {
this.sinks = sinks;
}

public _setEnrichers(enrichers: ReadonlyArray<ILogEventEnricher>) {
/** @internal */
public SetEnrichers(enrichers: ReadonlyArray<ILogEventEnricher>) {
this.enrichers = enrichers;
}

/** @internal */
public _setMinLogLevel(logLevel: LogLevel) {
/**
* Set the minimum log level for this logger
*/
public SetMinLogLevel(logLevel: LogLevel) {
this.logLevel = logLevel;
}

Expand Down
20 changes: 17 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { UserDefinedLogProperties } from "./Core/TypeUtils";
import { LogConfiguration } from "./Configuration";
import { LogEventRobloxOutputSink, RobloxOutputOptions } from "./Core/LogEventRobloxOutputSink";
import { Logger, LoggerContext } from "./Logger";
import { LogLevel } from "./Core";
export { Logger } from "./Logger";
export { LogLevel, LogEvent } from "./Core";

Expand All @@ -17,13 +18,19 @@ namespace Log {
}

/**
* Creates a custom logger
* @returns The logger configuration, use `Initialize` to get the logger once configured
* Configure a custom logger
*/
export function Create() {
export function Configure() {
return Logger.configure();
}

/**
* Creates a custom logger
* @returns The logger configuration, use `Initialize` to get the logger once configured
* @deprecated Use {@link Configure}. This will be removed in future.
*/
export const Create = Configure;

/**
* The default roblox output sink
* @param options Options for the sink
Expand Down Expand Up @@ -128,6 +135,13 @@ namespace Log {
.Create();
}

/**
* Set the minimum log level for the default logger
*/
export function SetMinLogLevel(logLevel: LogLevel) {
defaultLogger.SetMinLogLevel(logLevel);
}

/**
* Creates a logger that enriches log events with `SourceContext` as the specified function
*/
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"noLib": true,
"resolveJsonModule": true,
"strict": true,
"stripInternal": true,
"target": "ESNext",
"typeRoots": ["node_modules/@rbxts"],

Expand Down

0 comments on commit ec82aa9

Please sign in to comment.