Skip to content

Commit

Permalink
log fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
acharneski committed Nov 18, 2023
1 parent 4e1c606 commit d64fb46
Show file tree
Hide file tree
Showing 16 changed files with 63 additions and 47 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ repositories {
val kotlin_version = "1.9.20"
val jetty_version = "11.0.18"
val slf4j_version = "2.0.9"
val skyenet_version = "1.0.33"
val skyenet_version = "1.0.34"
dependencies {

implementation(group = "com.simiacryptus", name = "joe-penai", version = "1.0.31")
implementation(group = "com.simiacryptus", name = "joe-penai", version = "1.0.32")

implementation(group = "com.simiacryptus.skyenet", name = "core", version = skyenet_version)
implementation(group = "com.simiacryptus.skyenet", name = "webui", version = skyenet_version)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ abstract class BaseAction(
icon: Icon? = null,
) : AnAction(name, description, icon) {

val log by lazy { LoggerFactory.getLogger(javaClass) }
private val log by lazy { LoggerFactory.getLogger(javaClass) }
//override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT

val api: OpenAIClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VirtualFile
import org.slf4j.LoggerFactory
import java.io.File

abstract class FileContextAction<T : Any>(
Expand Down Expand Up @@ -76,4 +77,8 @@ abstract class FileContextAction<T : Any>(
return if (virtualFile.isDirectory) supportsFolders else supportsFiles
}

companion object {
private val log = LoggerFactory.getLogger(FileContextAction::class.java)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AppServer(
project: Project?
) {

val log by lazy { LoggerFactory.getLogger(javaClass) }
private val log by lazy { LoggerFactory.getLogger(javaClass) }

private var domainName: String = "http://$localName:$port"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.github.simiacryptus.aicoder.util.ComputerLanguage
import com.github.simiacryptus.aicoder.util.UITools
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import org.slf4j.LoggerFactory
import java.awt.Desktop
import java.util.*

Expand Down Expand Up @@ -36,4 +37,7 @@ class CodeChatAction : BaseAction() {
return !UITools.isSanctioned()
}

companion object {
private val log = LoggerFactory.getLogger(CodeChatAction::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile
import org.slf4j.LoggerFactory
import java.io.IOException
import java.util.concurrent.atomic.AtomicReference

Expand Down Expand Up @@ -50,31 +51,6 @@ class ConvertFileTo : ActionGroup() {
return actions.toArray(arrayOf())
}

companion object {

fun getNewFile(project: Project?, file: VirtualFile, language: ComputerLanguage): VirtualFile {
val newFileRef = AtomicReference<VirtualFile>()
WriteCommandAction.runWriteCommandAction(project) {
try {
val newFileName = file.nameWithoutExtension + "." + language.extensions[0]
newFileRef.set(file.parent.createChildData(file, newFileName))
} catch (ex: IOException) {
throw RuntimeException(ex)
}
}
return newFileRef.get()
}

fun write(project: Project?, newFile: VirtualFile, content: String) {
WriteCommandAction.runWriteCommandAction(project) {
try {
newFile.setBinaryContent(content.toByteArray())
} catch (e: IOException) {
throw RuntimeException(e)
}
}
}
}

class ConvertFileToLanguage(private val targetLanguage: ComputerLanguage) : BaseAction(
targetLanguage.name
Expand Down Expand Up @@ -103,4 +79,32 @@ class ConvertFileTo : ActionGroup() {
}

}

companion object {

fun getNewFile(project: Project?, file: VirtualFile, language: ComputerLanguage): VirtualFile {
val newFileRef = AtomicReference<VirtualFile>()
WriteCommandAction.runWriteCommandAction(project) {
try {
val newFileName = file.nameWithoutExtension + "." + language.extensions[0]
newFileRef.set(file.parent.createChildData(file, newFileName))
} catch (ex: IOException) {
throw RuntimeException(ex)
}
}
return newFileRef.get()
}

fun write(project: Project?, newFile: VirtualFile, content: String) {
WriteCommandAction.runWriteCommandAction(project) {
try {
newFile.setBinaryContent(content.toByteArray())
} catch (e: IOException) {
throw RuntimeException(e)
}
}
}

private val log = LoggerFactory.getLogger(ConvertFileTo::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.github.simiacryptus.aicoder.config.AppSettingsState
import com.github.simiacryptus.aicoder.util.UITools
import com.github.simiacryptus.aicoder.util.psi.PsiUtil
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.diagnostic.Logger
import org.slf4j.LoggerFactory

/**
* The PrintTreeAction class is an IntelliJ action that enables developers to print the tree structure of a PsiFile.
Expand All @@ -27,6 +27,6 @@ class PrintTreeAction : BaseAction() {
}

companion object {
val log = Logger.getInstance(PrintTreeAction::class.java)
private val log = LoggerFactory.getLogger(PrintTreeAction::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.actionSystem.PlatformDataKeys
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.diagnostic.Logger
import com.simiacryptus.util.audio.AudioRecorder
import com.simiacryptus.util.audio.LookbackLoudnessWindowBuffer
import org.slf4j.LoggerFactory
import java.util.*
import java.util.concurrent.ConcurrentLinkedDeque
import java.util.concurrent.Executors
Expand Down Expand Up @@ -122,7 +122,7 @@ class DictationAction : BaseAction() {
}

companion object {
val log = Logger.getInstance(DictationAction::class.java)
private val log = LoggerFactory.getLogger(DictationAction::class.java)

private val pool = Executors.newFixedThreadPool(1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ class ActionSettingsRegistry {

companion object {

val log = org.slf4j.LoggerFactory.getLogger(ActionSettingsRegistry::class.java)
private val log = org.slf4j.LoggerFactory.getLogger(ActionSettingsRegistry::class.java)

val actionCache = HashMap<String, AnAction>()
private fun load(actionPackage: String, actionName: String, language: String) =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.simiacryptus.aicoder.config

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.VerticalFlowLayout
Expand All @@ -12,6 +11,7 @@ import com.intellij.ui.components.JBScrollPane
import com.intellij.ui.components.panels.HorizontalLayout
import com.intellij.ui.table.JBTable
import org.jdesktop.swingx.JXTable
import org.slf4j.LoggerFactory
import java.awt.BorderLayout
import java.awt.event.ActionEvent
import java.util.*
Expand Down Expand Up @@ -44,9 +44,6 @@ class ActionTable(
}
}

companion object {
private val log = Logger.getInstance(ActionTable::class.java)
}

private val buttonPanel = JPanel()
val columnNames = arrayOf("Enabled", "Display Text", "ID")
Expand Down Expand Up @@ -218,4 +215,7 @@ class ActionTable(
buttonPanel.add(removeButton)
add(buttonPanel, BorderLayout.SOUTH)
}
companion object {
private val log = LoggerFactory.getLogger(ActionTable::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
package com.github.simiacryptus.aicoder.config

import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.fileEditor.FileEditorManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.ui.ComboBox
Expand All @@ -13,6 +12,7 @@ import com.intellij.ui.components.JBPasswordField
import com.intellij.ui.components.JBTextField
import com.simiacryptus.openai.models.ChatModels
import com.simiacryptus.openai.OpenAIClientBase
import org.slf4j.LoggerFactory
import java.awt.event.ActionEvent
import javax.swing.AbstractAction
import javax.swing.JButton
Expand Down Expand Up @@ -117,9 +117,7 @@ class AppSettingsComponent {
}

companion object {
private val log = Logger.getInstance(
AppSettingsComponent::class.java
)
private val log = LoggerFactory.getLogger(AppSettingsComponent::class.java)
//val ACTIONS_TOPIC = Topic.create("Actions", ActionChangedListener::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import javax.swing.ListModel

class ModelSelectionWidgetFactory : StatusBarWidgetFactory {
companion object {
val log = org.slf4j.LoggerFactory.getLogger(ModelSelectionWidgetFactory::class.java)
private val log = org.slf4j.LoggerFactory.getLogger(ModelSelectionWidgetFactory::class.java)
}

class ModelSelectionWidget : StatusBarWidget, StatusBarWidget.MultipleTextValuesPresentation {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import javax.swing.event.ChangeListener

class TemperatureControlWidgetFactory : StatusBarWidgetFactory {
companion object {
val log = org.slf4j.LoggerFactory.getLogger(TemperatureControlWidgetFactory::class.java)
private val log = org.slf4j.LoggerFactory.getLogger(TemperatureControlWidgetFactory::class.java)
val pool = Executors.newCachedThreadPool()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import java.util.concurrent.atomic.AtomicBoolean

class TokenCountWidgetFactory : StatusBarWidgetFactory {
companion object {
val log = org.slf4j.LoggerFactory.getLogger(TokenCountWidgetFactory::class.java)
private val log = org.slf4j.LoggerFactory.getLogger(TokenCountWidgetFactory::class.java)
val workQueue = LinkedBlockingDeque<Runnable>()
val pool = ThreadPoolExecutor(
/* corePoolSize = */ 1, /* maximumPoolSize = */ 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.simiacryptus.aicoder.util

import com.github.simiacryptus.aicoder.config.ActionTable
import com.github.simiacryptus.aicoder.config.AppSettingsState
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.application.ApplicationManager
Expand All @@ -12,6 +13,7 @@ import com.simiacryptus.openai.OpenAIClient
import com.simiacryptus.openai.models.OpenAITextModel
import com.simiacryptus.util.JsonUtil
import org.apache.hc.core5.http.HttpRequest
import org.slf4j.LoggerFactory
import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicReference
import javax.swing.JPanel
Expand Down Expand Up @@ -187,5 +189,8 @@ class IdeaOpenAIClient : OpenAIClient(
val project = lastEvent?.project ?: return function(request)
return function(JsonUtil.fromJson(uiEdit(project, title, JsonUtil.toJson(request)), request::class.java))
}

private val log = LoggerFactory.getLogger(IdeaOpenAIClient::class.java)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import com.github.simiacryptus.aicoder.util.ComputerLanguage
import com.github.simiacryptus.aicoder.util.IdeaOpenAIClient
import com.github.simiacryptus.aicoder.util.UITools.filterStringResult
import com.intellij.openapi.application.runReadAction
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiElementVisitor
import com.intellij.psi.PsiFile
import com.simiacryptus.openai.proxy.ChatProxy
import org.slf4j.LoggerFactory
import java.util.*
import java.util.concurrent.ExecutionException
import java.util.concurrent.TimeoutException
Expand Down Expand Up @@ -223,7 +223,7 @@ class PsiTranslationTree(

companion object {

val log = Logger.getInstance(PsiTranslationTree::class.java)
private val log = LoggerFactory.getLogger(PsiTranslationTree::class.java)

fun parseFile(
psiFile: PsiFile,
Expand Down

0 comments on commit d64fb46

Please sign in to comment.