Skip to content

Commit

Permalink
feat: possibility to initialize several times LogFlake
Browse files Browse the repository at this point in the history
  • Loading branch information
Dam998 committed May 8, 2024
1 parent dde548c commit 30cc7ac
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions lib/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,12 @@ export const getLogger = () => {
}

export const sendLog = (content: string, options?: SendLogOptionsType) => getLogger()?.sendLog(content, options)
export const sendException = (error: Error, options?: SendExceptionOptionsType) => getLogger()?.sendException(error, options)
export const sendException = <E extends Error>(error: E, options?: SendExceptionOptionsType) => getLogger()?.sendException(error, options)
export const measurePerformance = (label: string) => getLogger()?.measurePerformance(label)
export const sendPerformance = (label: string, duration: number) => getLogger()?.sendPerformance(label, duration)
export const changeCorrelation = (correlation: string) => getLogger()?.setCorrelation(correlation)

export function initialize(appId: string, server?: string, options?: IInitOptions) {
if (Logger !== null) {
throw new Error("LogFlake is already initialized, if you want to initialize a new instance, use the LogFlake class directly.")
}

Logger = new LogFlake(appId, server, options)
return Logger
}
Expand Down

0 comments on commit 30cc7ac

Please sign in to comment.