Skip to main content

Log Viewer With Claude Code Models

By Web Design7 min read

As a follow-up to yesterday’s agentic coding experiment, I wanted to try a more robust code endeavor with the various Claude Code models. Instead of a simple refactoring, this experiment includes creating a new page from scratch that doesn’t follow any of the prior art in the application. It’s an internal “log viewer” that only runs in the local development environment.

diff –git a/cfml/app/core/lib/util/Logger.cfc b/cfml/app/core/lib/util/Logger.cfc
index 9c9f10e..f7e2c50 100644
— a/cfml/app/core/lib/util/Logger.cfc
+++ b/cfml/app/core/lib/util/Logger.cfc
@@ -332,10 +332,9 @@ component hint = “I provide logging methods for errors and arbitrary data.” {
var stub = now().dateTimeFormat( “yyyy-mm-dd-HH-nn-ss” );
var suffix = lcase( payload.error.type ?: payload.level ?: “unknown” );

– writeDump(
– var = payload,
– format = “text”,
– output = expandPath( “/log/#stub#-#suffix#.txt” )
+ fileWrite(
+ expandPath( “/log/#stub#-#suffix#.json” ),
+ serializeJSON( payload )
);

}

diff –git a/cfml/app/wwwroot/internal/logs/index.cfm b/cfml/app/wwwroot/internal/logs/index.cfm
new file mode 100644
index 0000000..bba755a
— /dev/null
+++ b/cfml/app/wwwroot/internal/logs/index.cfm
@@ -0,0 +1,223 @@
+
+
+ // Define properties for dependency-injection.
+ config = request.ioc.get( “config” );
+ requestMetadata = request.ioc.get( “core.lib.web.RequestMetadata” );
+
+ // ColdFusion language extensions (global functions).
+ include “/core/cfmlx.cfm”;
+
+ // ——————————————————————————- //
+ // ——————————————————————————- //
+
+ // LOCAL DEVELOPMENT ONLY.
+ if ( config.isLive ) {
+
+ throw( type = “App.Forbidden” );
+
+ }
+
+ param name=”form.deleteLogs” type=”string” default=””;
+
+ if ( requestMetadata.isPost() && ( form.deleteLogs == “true” ) ) {
+
+ deleteAllLogs();
+ location( url = cgi.script_name, addToken = false );
+
+ }
+
+ logEntries = getLogEntries();
+
+ // ——————————————————————————- //
+ // ——————————————————————————- //
+
+ /**
+ * I delete all JSON log files in the /log directory.
+ */
+ private void function deleteAllLogs() {
+
+ var fileNames = directoryList(
+ path = expandPath( “/log” ),
+ listInfo = “name”,
+ filter = “*.json”
+ );
+
+ for ( var fileName in fileNames ) {
+
+ fileDelete( expandPath( “/log/#fileName#” ) );
+
+ }
+
+ }
+
+
+ /**
+ * I get the deserialized log entries from the /log directory, sorted newest-first.
+ */
+ private array function getLogEntries() {
+
+ var fileNames = directoryList(
+ path = expandPath( “/log” ),
+ listInfo = “name”,
+ filter = “*.json”,
+ sort = “name desc”
+ );
+
+ var entries = [];
+
+ for ( var fileName in fileNames ) {
+
+ entries.append({
+ filename: fileName,
+ data: deserializeJSON( fileRead( expandPath( “/log/#fileName#” ) ) )
+ });
+
+ }
+
+ return entries;
+
+ }
+
+

+
+
+
+
+
+ Local Development Logs
+
+
+
+


+
+
+
+
+
+
+
+
+
+

+

+ #e( coalesceTruthy( entry.data?.error?.message, entry.data?.error?.type, entry.data?.message, entry.filename ) )#
+

+

+

+
+
+
+
+
+

+ No log entries found.
+

+
+
+
+

+
+

+
+
+
+


+
+


Source link