diff --git a/docs/README.md b/docs/README.md index 8f83cd9..9710e76 100644 --- a/docs/README.md +++ b/docs/README.md @@ -426,12 +426,14 @@ Following settings are available for styling: - `{{nameWithDelimiterSuffix}}`: optional name of the current logger (s. above) with a delimiter at the end - `{{fullFilePath}}`: a full path starting from `/` root - `{{filePathWithLine}}`: a full path below the project path with line number + - `{{fileNameWithLine}}`: file name with line number - `prettyErrorTemplate`: template string for error message. Possible placeholders: - `{{errorName}}`: name of the error - `{{errorMessage}}`: error message - `{{errorStack}}`: Placeholder for all stack lines defined by `prettyErrorStackTemplate` - `prettyErrorStackTemplate`: template string for error stack trace lines. Possible placeholders: - `{{fileName}}`: name of the file + - `{{fileNameWithLine}}`: file name with line number - `{{filePathWithLine}}`: a full path below the project path with a line number - `{{method}}`: _optional_ name of the invoking method - `prettyErrorParentNamesSeparator`: separator to be used when joining names ot the parent logger, and the current one (default: `:`) @@ -483,6 +485,7 @@ const logger = new Logger({ nameWithDelimiterSuffix: ["white", "bold"], errorName: ["bold", "bgRedBright", "whiteBright"], fileName: ["yellow"], + fileNameWithLine: "white", }, }); diff --git a/src/BaseLogger.ts b/src/BaseLogger.ts index 5403887..76742d6 100644 --- a/src/BaseLogger.ts +++ b/src/BaseLogger.ts @@ -118,8 +118,8 @@ export class BaseLogger { } if (this.settings.type === "pretty") { - logMetaMarkup = this._prettyFormatLogObjMeta(logObjWithMeta?.[this.settings.metaProperty]); - logArgsAndErrorsMarkup = prettyFormatLogObj(maskedArgs, this.settings); + logMetaMarkup = logMetaMarkup ?? this._prettyFormatLogObjMeta(logObjWithMeta?.[this.settings.metaProperty]); + logArgsAndErrorsMarkup = logArgsAndErrorsMarkup ?? prettyFormatLogObj(maskedArgs, this.settings); } if (logMetaMarkup != null && logArgsAndErrorsMarkup != null) { diff --git a/src/runtime/browser/index.ts b/src/runtime/browser/index.ts index 4b94253..7b6accb 100644 --- a/src/runtime/browser/index.ts +++ b/src/runtime/browser/index.ts @@ -64,7 +64,7 @@ export function getCallerStackFrame(stackDepthLevel: number): IStackFrame { const filePath = pathArray?.pop()?.split("?")?.[0]; const fileName = filePath?.split("/").pop(); const fileNameWithLine = `${fileName}:${fileLine}`; - const filePathWithLine = `${filePath}:${fileLine}`; + const filePathWithLine = `${href}${filePath}:${fileLine}`; const errorStackLine = fullFilePath?.split(" ("); return { fullFilePath, @@ -118,7 +118,7 @@ export function getErrorTrace(error: Error): IStackFrame[] { const filePath = pathArray?.pop()?.split("?")[0]; const fileName = filePath?.split("/")?.pop()?.split("?")[0]; const fileNameWithLine = `${fileName}:${fileLine}`; - const filePathWithLine = `${filePath}:${fileLine}`; + const filePathWithLine = `${href}${filePath}:${fileLine}`; if (filePath != null && filePath.length > 0) { result.push({