Skip to content

Commit c87ca58

Browse files
committed
Refactor log variable naming from 'LOG' to 'log'
Renamed 'LOG' to 'log' across all classes for consistency and adherence to Kotlin naming conventions. This change improves code readability and maintains uniform style in logging practices.
1 parent f18e859 commit c87ca58

2 files changed

Lines changed: 49 additions & 49 deletions

File tree

src/main/kotlin/il/co/sysbind/intellij/moodledev/project/MoodleSettingsForm.kt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ import javax.swing.JComponent
3434
import javax.swing.JTextField
3535

3636
class MoodleSettingsForm(val project: Project) : PhpFrameworkConfigurable {
37-
private val LOG = Logger.getInstance(MoodleSettingsForm::class.java)
37+
private val log = Logger.getInstance(MoodleSettingsForm::class.java)
3838
private val settings = project.getService(MoodleProjectSettings::class.java).settings
3939
lateinit var pluginEnabled: Cell<JBCheckBox>
4040
private set
@@ -94,7 +94,7 @@ class MoodleSettingsForm(val project: Project) : PhpFrameworkConfigurable {
9494
NotificationType.WARNING
9595
)
9696
.notify(project)
97-
LOG.warn("Composer is not available, skipping PHP_Codesniffer configuration")
97+
log.warn("Composer is not available, skipping PHP_Codesniffer configuration")
9898
} else {
9999
val detectedPhpcsPath = ComposerUtil.getPhpcsPath()
100100
val detectedPhpcbfPath = ComposerUtil.getPhpcbfPath()
@@ -127,14 +127,14 @@ class MoodleSettingsForm(val project: Project) : PhpFrameworkConfigurable {
127127
val profileManager = InspectionProjectProfileManager.getInstance(project)
128128
val profile = profileManager.currentProfile
129129
profile.setToolEnabled("PhpCSValidationInspection", true)
130-
LOG.info("Successfully enabled PhpCSValidationInspection")
130+
log.info("Successfully enabled PhpCSValidationInspection")
131131

132132
// Try to set the configuration for phpcs_by_interpreter
133133
try {
134134
manager.markAndSetNewSettings(listOf(configuration))
135-
LOG.info("Successfully set tool path for phpcs_by_interpreter")
135+
log.info("Successfully set tool path for phpcs_by_interpreter")
136136
} catch (e: Exception) {
137-
LOG.warn("Could not set tool path for phpcs_by_interpreter: ${e.message}")
137+
log.warn("Could not set tool path for phpcs_by_interpreter: ${e.message}")
138138
}
139139

140140
// Show success notification
@@ -147,33 +147,33 @@ class MoodleSettingsForm(val project: Project) : PhpFrameworkConfigurable {
147147
)
148148
.notify(project)
149149

150-
LOG.info("Successfully configured PHP_Codesniffer automatically")
150+
log.info("Successfully configured PHP_Codesniffer automatically")
151151
}
152152
} catch (e: Exception) {
153-
LOG.error("Failed to configure PHP_Codesniffer automatically: ${e.message}", e)
153+
log.error("Failed to configure PHP_Codesniffer automatically: ${e.message}", e)
154154
}
155155
})
156156
.addAction(NotificationAction.createSimple(MoodleBundle.getMessage("configurable.phpcs.open.settings")) {
157157
ShowSettingsUtil.getInstance().showSettingsDialog(
158158
project,
159159
MoodleBundle.getMessage("configurable.phpcs.settings.path")
160160
)
161-
LOG.info("Opened PHP_Codesniffer settings")
161+
log.info("Opened PHP_Codesniffer settings")
162162
})
163163
.addAction(NotificationAction.createSimple(MoodleBundle.getMessage("configurable.phpcs.copy.paths")) {
164164
val content = MoodleBundle.getMessage("configurable.phpcs.paths.content", detectedPhpcsPath, detectedPhpcbfPath)
165165
val clipboard = com.intellij.openapi.ide.CopyPasteManager.getInstance()
166166
clipboard.setContents(java.awt.datatransfer.StringSelection(content))
167-
LOG.info("Copied PHP_Codesniffer paths to clipboard")
167+
log.info("Copied PHP_Codesniffer paths to clipboard")
168168
})
169169
.addAction(NotificationAction.createSimple(MoodleBundle.getMessage("configurable.phpcs.ignore")) {
170-
LOG.info("User chose to ignore PHP_Codesniffer configuration")
170+
log.info("User chose to ignore PHP_Codesniffer configuration")
171171
})
172172
.notify(project)
173173

174-
LOG.info("Showed PHP_Codesniffer configuration options to user")
174+
log.info("Showed PHP_Codesniffer configuration options to user")
175175
} else {
176-
LOG.warn("Failed to get PHP_Codesniffer paths from composer global directory")
176+
log.warn("Failed to get PHP_Codesniffer paths from composer global directory")
177177
}
178178
}
179179
}
@@ -187,10 +187,10 @@ class MoodleSettingsForm(val project: Project) : PhpFrameworkConfigurable {
187187
// Setup Moodle CS via Composer if composer is available
188188
if (ComposerUtil.isComposerAvailable()) {
189189
if (!ComposerUtil.setupMoodleCs(project)) {
190-
LOG.warn("Failed to setup Moodle CS via Composer")
190+
log.warn("Failed to setup Moodle CS via Composer")
191191
}
192192
} else {
193-
LOG.warn("Composer is not available, skipping Moodle CS setup")
193+
log.warn("Composer is not available, skipping Moodle CS setup")
194194
}
195195

196196
val codeStyleSettings = CodeStyle.getSettings(project)
@@ -212,10 +212,10 @@ class MoodleSettingsForm(val project: Project) : PhpFrameworkConfigurable {
212212
// If paths are equal, run composer install if composer is available
213213
if (ComposerUtil.isComposerAvailable()) {
214214
if (!ComposerUtil.runComposerInstall(project, moodlePathStr)) {
215-
LOG.warn("Failed to run composer install in $moodlePathStr")
215+
log.warn("Failed to run composer install in $moodlePathStr")
216216
}
217217
} else {
218-
LOG.warn("Composer is not available, skipping composer install in $moodlePathStr")
218+
log.warn("Composer is not available, skipping composer install in $moodlePathStr")
219219
}
220220
} else if (!includePathList.contains(moodlePathStr)) {
221221
// If paths are different and the Moodle path is not in include paths, add it

src/main/kotlin/il/co/sysbind/intellij/moodledev/util/ComposerUtil.kt

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import com.intellij.openapi.project.Project
99
import com.intellij.openapi.util.Key
1010

1111
object ComposerUtil {
12-
private val LOG = Logger.getInstance(ComposerUtil::class.java)
12+
private val log = Logger.getInstance(ComposerUtil::class.java)
1313
private var composerGlobalDir: String? = null
1414
private var isComposerAvailable: Boolean? = null
1515

@@ -31,10 +31,10 @@ object ComposerUtil {
3131
processHandler.waitFor()
3232

3333
isComposerAvailable = processHandler.exitCode == 0
34-
LOG.debug("Composer availability check: $isComposerAvailable")
34+
log.debug("Composer availability check: $isComposerAvailable")
3535
return isComposerAvailable!!
3636
} catch (e: Exception) {
37-
LOG.warn("Failed to check composer availability: ${e.message}")
37+
log.warn("Failed to check composer availability: ${e.message}")
3838
isComposerAvailable = false
3939
return false
4040
}
@@ -69,16 +69,16 @@ object ComposerUtil {
6969
if (processHandler.exitCode == 0 && output.isNotEmpty()) {
7070
// Clean up the output - remove any extra whitespace or newlines
7171
composerGlobalDir = output.toString().trim()
72-
LOG.debug("Found composer global directory: $composerGlobalDir")
72+
log.debug("Found composer global directory: $composerGlobalDir")
7373
return composerGlobalDir
7474
} else {
75-
LOG.warn("Composer command exited with code ${processHandler.exitCode} or empty output")
75+
log.warn("Composer command exited with code ${processHandler.exitCode} or empty output")
7676
}
7777
} catch (e: Exception) {
78-
LOG.error("Failed to get composer global directory: ${e.message}", e)
78+
log.error("Failed to get composer global directory: ${e.message}", e)
7979
}
8080
} else {
81-
LOG.warn("Composer is not available, falling back to default locations")
81+
log.warn("Composer is not available, falling back to default locations")
8282
}
8383

8484
// Fallback to default locations if composer command fails
@@ -91,13 +91,13 @@ object ComposerUtil {
9191
for (location in possibleLocations) {
9292
val dir = java.io.File(location)
9393
if (dir.exists() && dir.isDirectory) {
94-
LOG.debug("Using fallback composer global directory: $location")
94+
log.debug("Using fallback composer global directory: $location")
9595
composerGlobalDir = location
9696
return composerGlobalDir
9797
}
9898
}
9999

100-
LOG.warn("Could not determine composer global directory")
100+
log.warn("Could not determine composer global directory")
101101
return null
102102
}
103103

@@ -130,13 +130,13 @@ object ComposerUtil {
130130
fun runComposerInstall(project: Project, directory: String): Boolean {
131131
// First check if composer is available
132132
if (!isComposerAvailable()) {
133-
LOG.warn("Composer is not available, skipping composer install")
133+
log.warn("Composer is not available, skipping composer install")
134134
return false
135135
}
136136

137137
val workDir = java.io.File(directory)
138138
if (!workDir.exists() || !workDir.isDirectory) {
139-
LOG.debug("Directory does not exist or is not a directory: $directory")
139+
log.debug("Directory does not exist or is not a directory: $directory")
140140
return false
141141
}
142142

@@ -148,12 +148,12 @@ object ComposerUtil {
148148
val processHandler = OSProcessHandler(commandLine)
149149
processHandler.addProcessListener(object : ProcessAdapter() {
150150
override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) {
151-
LOG.debug("Composer install output: ${event.text}")
151+
log.debug("Composer install output: ${event.text}")
152152
}
153153

154154
override fun processTerminated(event: ProcessEvent) {
155155
if (event.exitCode != 0) {
156-
LOG.warn("Composer install failed with exit code: ${event.exitCode}")
156+
log.warn("Composer install failed with exit code: ${event.exitCode}")
157157
}
158158
}
159159
})
@@ -163,17 +163,17 @@ object ComposerUtil {
163163

164164
return processHandler.exitCode == 0
165165
} catch (e: Exception) {
166-
LOG.error("Failed to run composer install: ${e.message}", e)
166+
log.error("Failed to run composer install: ${e.message}", e)
167167
return false
168168
}
169169
}
170170

171171
fun setupMoodleCs(project: Project): Boolean {
172-
LOG.debug("Setting up Moodle CS...")
172+
log.debug("Setting up Moodle CS...")
173173

174174
// First check if composer is available
175175
if (!isComposerAvailable()) {
176-
LOG.warn("Composer is not available, skipping Moodle CS setup")
176+
log.warn("Composer is not available, skipping Moodle CS setup")
177177
return false
178178
}
179179

@@ -186,7 +186,7 @@ object ComposerUtil {
186186
val phpcbfFile = java.io.File(phpcbfPath)
187187

188188
if (phpcsFile.exists() && phpcbfFile.exists()) {
189-
LOG.debug("PHPCS and PHPCBF already exist, checking if moodle standard is available")
189+
log.debug("PHPCS and PHPCBF already exist, checking if moodle standard is available")
190190

191191
// Check if moodle standard is available
192192
try {
@@ -205,32 +205,32 @@ object ComposerUtil {
205205
processHandler.waitFor()
206206

207207
if (processHandler.exitCode == 0 && output.toString().lowercase().contains("moodle")) {
208-
LOG.debug("Moodle standard is already available")
208+
log.debug("Moodle standard is already available")
209209
return true
210210
}
211211
} catch (e: Exception) {
212-
LOG.warn("Failed to check if moodle standard is available: ${e.message}")
212+
log.warn("Failed to check if moodle standard is available: ${e.message}")
213213
// Continue with setup
214214
}
215215
}
216216
}
217217

218218
try {
219219
// Set minimum-stability to dev
220-
LOG.debug("Setting composer minimum-stability to dev")
220+
log.debug("Setting composer minimum-stability to dev")
221221
if (!executeComposerCommand(project, listOf("global", "config", "minimum-stability", "dev"))) {
222-
LOG.warn("Failed to set composer minimum-stability to dev, but continuing with installation")
222+
log.warn("Failed to set composer minimum-stability to dev, but continuing with installation")
223223
}
224224

225225
// Install moodlehq/moodle-cs
226-
LOG.debug("Installing moodlehq/moodle-cs")
226+
log.debug("Installing moodlehq/moodle-cs")
227227
if (!executeComposerCommand(project, listOf("global", "require", "moodlehq/moodle-cs"))) {
228-
LOG.error("Failed to install moodlehq/moodle-cs")
228+
log.error("Failed to install moodlehq/moodle-cs")
229229

230230
// Try alternative approach - install with --dev flag
231-
LOG.debug("Trying alternative approach with --dev flag")
231+
log.debug("Trying alternative approach with --dev flag")
232232
if (!executeComposerCommand(project, listOf("global", "require", "--dev", "moodlehq/moodle-cs"))) {
233-
LOG.error("Failed to install moodlehq/moodle-cs with --dev flag")
233+
log.error("Failed to install moodlehq/moodle-cs with --dev flag")
234234
return false
235235
}
236236
}
@@ -244,23 +244,23 @@ object ComposerUtil {
244244
val newPhpcbfFile = java.io.File(newPhpcbfPath)
245245

246246
if (newPhpcsFile.exists() && newPhpcbfFile.exists()) {
247-
LOG.debug("Successfully installed PHPCS and PHPCBF")
247+
log.debug("Successfully installed PHPCS and PHPCBF")
248248
return true
249249
}
250250
}
251251

252-
LOG.warn("PHPCS or PHPCBF not found after installation")
252+
log.warn("PHPCS or PHPCBF not found after installation")
253253
return false
254254
} catch (e: Exception) {
255-
LOG.error("Error setting up Moodle CS: ${e.message}", e)
255+
log.error("Error setting up Moodle CS: ${e.message}", e)
256256
return false
257257
}
258258
}
259259

260260
private fun executeComposerCommand(project: Project, arguments: List<String>): Boolean {
261261
// First check if composer is available
262262
if (!isComposerAvailable()) {
263-
LOG.warn("Composer is not available, skipping composer command: ${arguments.joinToString(" ")}")
263+
log.warn("Composer is not available, skipping composer command: ${arguments.joinToString(" ")}")
264264
return false
265265
}
266266

@@ -274,13 +274,13 @@ object ComposerUtil {
274274
val processHandler = OSProcessHandler(commandLine)
275275
processHandler.addProcessListener(object : ProcessAdapter() {
276276
override fun onTextAvailable(event: ProcessEvent, outputType: Key<*>) {
277-
LOG.debug("Composer output: ${event.text}")
277+
log.debug("Composer output: ${event.text}")
278278
}
279279

280280
override fun processTerminated(event: ProcessEvent) {
281281
success = event.exitCode == 0
282282
if (!success) {
283-
LOG.warn("Composer command failed with exit code: ${event.exitCode}")
283+
log.warn("Composer command failed with exit code: ${event.exitCode}")
284284
}
285285
}
286286
})
@@ -290,8 +290,8 @@ object ComposerUtil {
290290

291291
return success
292292
} catch (e: Exception) {
293-
LOG.error("Failed to execute composer command: ${e.message}", e)
293+
log.error("Failed to execute composer command: ${e.message}", e)
294294
return false
295295
}
296296
}
297-
}
297+
}

0 commit comments

Comments
 (0)