Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add option to log only filename - W/O line number #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ Properties:

- turboConsoleLog.delemiterInsideMessage (string): The delimiter that will separate the different log message elements (file name, line number, class, function and variable)

- turboConsoleLog.includeFileName (boolean): Whether to include the file name of the log message.

- turboConsoleLog.includeFileNameAndLineNum (boolean): Whether to include the file name and the line number of the log message.

- turboConsoleLog.quote (enum): Double quotes (""), single quotes ('') or backtick(``).
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@
"default": "🚀",
"description": "The prefix of the log message."
},
"turboConsoleLog.includeFileName": {
"type": "boolean",
"default": false,
"description": "Whether to include the file name of the log message."
},
"turboConsoleLog.includeFileNameAndLineNum": {
"type": "boolean",
"default": true,
"description": "Whether to include the file name and the line number of the log message."
"description": "Whether to include the file name and the line number of the log message. If includeFileNameAndLineNum is true this will override it and the filename and line number will be displayed."
},
"turboConsoleLog.addSemicolonInTheEnd": {
"type": "boolean",
Expand Down
1 change: 1 addition & 0 deletions src/debug-message/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export abstract class DebugMessage {
insertEnclosingClass: boolean,
insertEnclosingFunction: boolean,
delemiterInsideMessage: string,
includeFileName: boolean,
includeFileNameAndLineNum: boolean,
tabSize: number
): string;
Expand Down
6 changes: 6 additions & 0 deletions src/debug-message/js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class JSDebugMessage extends DebugMessage {
insertEnclosingClass: boolean,
insertEnclosingFunction: boolean,
delemiterInsideMessage: string,
includeFileName: boolean,
includeFileNameAndLineNum: boolean,
tabSize: number
): string {
Expand Down Expand Up @@ -46,6 +47,7 @@ export class JSDebugMessage extends DebugMessage {
? document.fileName.split("/")[document.fileName.split("/").length - 1]
: document.fileName.split("\\")[document.fileName.split("\\").length - 1];
if (
!includeFileName &&
!includeFileNameAndLineNum &&
!insertEnclosingFunction &&
!insertEnclosingClass &&
Expand All @@ -58,6 +60,10 @@ export class JSDebugMessage extends DebugMessage {
logMessagePrefix !== `${delemiterInsideMessage} `
? ` ${delemiterInsideMessage} `
: ""
}${
includeFileName
? `file: ${fileName} ${delemiterInsideMessage} `
: ""
}${
includeFileNameAndLineNum
? `file: ${fileName} ${delemiterInsideMessage} line ${
Expand Down
1 change: 1 addition & 0 deletions src/entities/extensionProperties.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export type ExtensionProperties = {
insertEnclosingClass: boolean;
insertEnclosingFunction: boolean;
delimiterInsideMessage: string;
includeFileName: boolean;
includeFileNameAndLineNum: boolean;
quote: string;
};
4 changes: 4 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export function activate(context: vscode.ExtensionContext) {
properties.insertEnclosingClass,
properties.insertEnclosingFunction,
properties.delimiterInsideMessage,
properties.includeFileName,
properties.includeFileNameAndLineNum,
tabSize
)
Expand Down Expand Up @@ -176,6 +177,8 @@ function getExtensionProperties(
const insertEnclosingFunction = workspaceConfig.insertEnclosingFunction;
const quote = workspaceConfig.quote || '"';
const delimiterInsideMessage = workspaceConfig.delimiterInsideMessage || "~";
const includeFileName =
workspaceConfig.includeFileName || false;
const includeFileNameAndLineNum =
workspaceConfig.includeFileNameAndLineNum || false;
const extensionProperties: ExtensionProperties = {
Expand All @@ -186,6 +189,7 @@ function getExtensionProperties(
insertEnclosingFunction,
quote,
delimiterInsideMessage,
includeFileName,
includeFileNameAndLineNum,
};
return extensionProperties;
Expand Down