Skip to content

Commit

Permalink
Merge pull request #43 from vkhobor/add-prettyfy-json
Browse files Browse the repository at this point in the history
Use indentation for JSON logs
  • Loading branch information
kevincobain2000 authored Jan 22, 2025
2 parents eb70a96 + 92c3cf3 commit 74193f9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
11 changes: 10 additions & 1 deletion frontend/dist/index.html

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions frontend/src/components/JS.astro
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@
return number > 999 ? (number / 1000).toFixed(1) + "k" : number;
}

function formatLogString(str) {
try {
const json = JSON.parse(str);
return JSON.stringify(json, null, 2);
} catch (e) {
return str;
}
}

function timeago(str) {
if (!str) return "";
date = new Date(str);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/components/partials/viewer/Table.astro
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
<span class="uppercase" x-text="item.agent.device"></span>
</td>
<td><span class="text-sm" x-text="timeago(item.date)"></span></td>
<td class="px-3 py-2 text-blue-200" x-text="item.content"></td>
<td class="px-3 py-2 text-blue-200 whitespace-pre-wrap" x-text="formatLogString(item.content)"></td>
</tr>
</template>
</tbody>
Expand Down

0 comments on commit 74193f9

Please sign in to comment.