Skip to content

Commit 00706be

Browse files
committed
refactor(logging): make logger instances private and use the logger<T> method to retrieve them. #51
1 parent 27d1269 commit 00706be

File tree

17 files changed

+21
-27
lines changed

17 files changed

+21
-27
lines changed

exts/database/src/main/kotlin/cc/unitmesh/database/actions/GenerateFunctionAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class GenerateFunctionAction : ChatBaseIntention() {
1919

2020
override fun getText(): String = AutoDevBundle.message("migration.database.plsql.generate.function")
2121

22-
val logger = logger<GenerateFunctionAction>()
22+
private val logger = logger<GenerateFunctionAction>()
2323

2424
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?): Boolean {
2525
if (editor == null || file == null) return false

exts/database/src/main/kotlin/cc/unitmesh/database/actions/GenerateUnittestAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class GenerateUnittestAction : ChatBaseIntention() {
2424
return file.language is OraDialect
2525
}
2626

27-
val logger = logger<GenerateUnittestAction>()
27+
private val logger = logger<GenerateUnittestAction>()
2828

2929
override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {
3030
if (editor == null || file == null) return

java/src/main/kotlin/cc/unitmesh/idea/actions/AutoCrudAction.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import com.intellij.openapi.util.NlsSafe
1616
import com.intellij.psi.PsiFile
1717

1818
class AutoCrudAction : ChatBaseIntention() {
19+
private val logger = logger<AutoCrudAction>()
20+
1921
override fun priority(): Int = 900
2022

2123
override fun getText(): String = AutoDevBundle.message("intentions.crud.new.name")
@@ -75,7 +77,4 @@ class AutoCrudAction : ChatBaseIntention() {
7577
}
7678

7779

78-
companion object {
79-
val logger = logger<AutoCrudAction>()
80-
}
8180
}

java/src/main/kotlin/cc/unitmesh/idea/context/JavaContextCollection.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import com.intellij.psi.search.searches.MethodReferencesSearch
1111
import com.intellij.psi.search.searches.ReferencesSearch
1212

1313
object JavaContextCollection {
14-
val logger = logger<JavaContextCollection>()
14+
private val logger = logger<JavaContextCollection>()
1515
fun findUsages(nameIdentifierOwner: PsiNameIdentifierOwner): List<PsiReference> {
1616
val project = nameIdentifierOwner.project
1717
val searchScope = GlobalSearchScope.allScope(project) as SearchScope

java/src/main/kotlin/cc/unitmesh/idea/prompting/JavaContextPrompter.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.intellij.temporary.similar.chunks.SimilarChunksWithPaths
2121
import kotlinx.coroutines.runBlocking
2222

2323
open class JavaContextPrompter : ContextPrompter() {
24+
private val logger = logger<JavaContextPrompter>()
2425
private var additionContext: String = ""
2526
protected open val testDataBuilder: TestDataBuilder = JavaTestDataBuilder()
2627

@@ -167,7 +168,4 @@ open class JavaContextPrompter : ContextPrompter() {
167168
}
168169
}
169170

170-
companion object {
171-
val logger = logger<JavaContextPrompter>()
172-
}
173171
}

src/main/kotlin/cc/unitmesh/devti/actions/console/FixThisAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import com.intellij.temporary.error.ErrorMessageProcessor
1212

1313
class FixThisAction : ChatBaseAction() {
1414
override fun getActionType(): ChatActionType = ChatActionType.FIX_ISSUE
15-
val logger = logger<FixThisAction>()
15+
private val logger = logger<FixThisAction>()
1616

1717
override fun actionPerformed(event: AnActionEvent) {
1818
val project = event.project ?: return

src/main/kotlin/cc/unitmesh/devti/actions/vcs/CommitMessageSuggestionAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CommitMessageSuggestionAction : ChatBaseAction() {
3232
return ActionUpdateThread.BGT
3333
}
3434

35-
val logger = logger<CommitMessageSuggestionAction>()
35+
private val logger = logger<CommitMessageSuggestionAction>()
3636

3737
override fun getActionType(): ChatActionType = ChatActionType.GEN_COMMIT_MESSAGE
3838

src/main/kotlin/cc/unitmesh/devti/actions/vcs/ReleaseNoteSuggestionAction.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ import com.intellij.vcs.log.VcsLogDataKeys
1313

1414

1515
class ReleaseNoteSuggestionAction : AnAction() {
16-
companion object {
17-
val logger = logger<ReleaseNoteSuggestionAction>()
18-
}
19-
2016
override fun actionPerformed(e: AnActionEvent) {
2117
val project = e.project
2218
val vcsLog = e.getData(VcsLogDataKeys.VCS_LOG)

src/main/kotlin/cc/unitmesh/devti/custom/document/CustomLivingDocTask.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ class CustomLivingDocTask(
1616
val config: CustomDocumentationConfig,
1717
) :
1818
Task.Backgroundable(editor.project, config.title) {
19-
20-
companion object {
21-
val logger = logger<CustomLivingDocTask>()
22-
}
19+
private val logger = logger<CustomLivingDocTask>()
2320

2421
override fun run(indicator: ProgressIndicator) {
2522
val documentation = LivingDocumentation.forLanguage(target.language) ?: return

src/main/kotlin/cc/unitmesh/devti/custom/team/CustomActionPrompt.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ data class CustomActionPrompt(
1919
var msgs: List<LlmMsg.ChatMessage> = listOf(),
2020
) {
2121
companion object {
22-
val logger = logger<CustomActionPrompt>()
22+
private val logger = logger<CustomActionPrompt>()
2323

2424
/**
2525
* Parses the given content and returns a TeamActionPrompt object.

src/main/kotlin/cc/unitmesh/devti/gui/chat/ChatCodingPanel.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import cc.unitmesh.devti.provider.ContextPrompter
88
import cc.unitmesh.devti.settings.AutoDevSettingsState
99
import com.intellij.ide.BrowserUtil
1010
import com.intellij.openapi.Disposable
11+
import com.intellij.openapi.diagnostic.logger
1112
import com.intellij.openapi.ui.DialogPanel
1213
import com.intellij.openapi.ui.NullableComponent
1314
import com.intellij.openapi.ui.SimpleToolWindowPanel
@@ -196,14 +197,17 @@ class ChatCodingPanel(private val chatCodingService: ChatCodingService, val disp
196197
updateUI()
197198
}
198199

200+
private val logger = logger<ChatCodingPanel>()
201+
199202
private suspend fun updateMessageInUi(content: Flow<String>): String {
200203
val messageView = MessageView("", ChatRole.Assistant, "")
201204
myList.add(messageView)
202205
val startTime = System.currentTimeMillis() // 记录代码开始执行的时间
203206

204207
var text = ""
205208
content.onCompletion {
206-
println("onCompletion ${it?.message}")
209+
// println("onCompletion ${it?.message}")
210+
logger.info("onCompletion ${it?.message}")
207211
}.catch {
208212
it.printStackTrace()
209213
}.collect {

src/main/kotlin/cc/unitmesh/devti/gui/toolbar/NewChatAction.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import javax.swing.JButton
1515
import javax.swing.JComponent
1616

1717
class NewChatAction : DumbAwareAction(), CustomComponentAction {
18-
val logger = logger<NewChatAction>()
18+
private val logger = logger<NewChatAction>()
1919

2020
override fun actionPerformed(e: AnActionEvent) {
2121

src/main/kotlin/cc/unitmesh/devti/intentions/action/CodeCompletionBaseIntention.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@ class CodeCompletionBaseIntention : ChatBaseIntention() {
6363
}
6464

6565
companion object {
66-
val logger = logger<CodeCompletionBaseIntention>()
66+
private val logger = logger<CodeCompletionBaseIntention>()
6767
}
6868
}

src/main/kotlin/cc/unitmesh/devti/intentions/action/base/BasedDocumentationBaseIntention.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ abstract class BasedDocumentationBaseIntention : ChatBaseIntention() {
2121

2222
override fun startInWriteAction(): Boolean = false
2323

24-
val logger = logger<BasedDocumentationBaseIntention>()
24+
private val logger = logger<BasedDocumentationBaseIntention>()
2525

2626
override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {
2727
if (editor == null || file == null) return

src/main/kotlin/cc/unitmesh/devti/intentions/action/task/BaseCompletionTask.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,6 @@ abstract class BaseCompletionTask(private val request: CodeCompletionRequest) :
9090
}
9191

9292
companion object {
93-
val logger = logger<CodeCompletionBaseIntention>()
93+
private val logger = logger<CodeCompletionBaseIntention>()
9494
}
9595
}

src/main/kotlin/cc/unitmesh/devti/intentions/action/task/LivingDocumentationTask.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class LivingDocumentationTask(
5151
}
5252

5353
companion object {
54-
val logger = logger<LivingDocumentationTask>()
54+
private val logger = logger<LivingDocumentationTask>()
5555
}
5656
}
5757

src/main/kotlin/cc/unitmesh/devti/util/LLMCoroutineScope.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import kotlinx.coroutines.CoroutineExceptionHandler
88
import kotlinx.coroutines.CoroutineScope
99
import kotlinx.coroutines.SupervisorJob
1010

11-
val logger = Logger.getInstance(LLMCoroutineScope::class.java)
11+
private val logger = Logger.getInstance(LLMCoroutineScope::class.java)
1212

1313
val coroutineExceptionHandler = CoroutineExceptionHandler { _, throwable ->
1414
logger.error(throwable)

0 commit comments

Comments
 (0)