Skip to content

Instantly share code, notes, and snippets.

@francislavoie
francislavoie / TimestampOutput.md
Last active April 28, 2024 08:10
A Symfony OutputInterface decorator that inserts timestamps on every line

A Symfony OutputInterface decorator that inserts timestamps on every line

I'm kinda proud of this, but it took me way too long to come up with the right solution 😅 I also couldn't find anyone on the internet who wrote something like this, so I'm sharing it in case others find it useful.

This can be used to wrap an $output in any CLI command, it will intercept all the newlines being printed out and insert the current time at the start of every line.

Easier said than done, because if we just naively insert dates after each newline, then the timestamp of a line would be the time from the previous message, not the current line being printed. So to correct that, we need to keep track of whether the previous write inserted a final newline, and if so prepend a date; and we need to skip adding a date on the last newline of that write.

Usage:

@francislavoie
francislavoie / induced.txt
Created June 7, 2022 06:23
deep-js-completion
Following exceptions happened soon after this one, most probably they are induced.
2022-06-07T00:59:13.482
java.lang.Throwable: Must be executed under progress indicator: com.intellij.openapi.progress.EmptyProgressIndicator@78005c2a. Please see e.g. ProgressManager.runProcess()
at com.intellij.openapi.diagnostic.Logger.error(Logger.java:182)
at com.intellij.openapi.progress.impl.CoreProgressManager.assertUnderProgress(CoreProgressManager.java:996)
at com.intellij.psi.impl.search.PsiSearchHelperImpl.processFilesConcurrentlyDespiteWriteActions(PsiSearchHelperImpl.java:428)
at com.intellij.psi.impl.search.PsiSearchHelperImpl.lambda$processPsiFileRoots$8(PsiSearchHelperImpl.java:397)
at com.intellij.psi.impl.PsiManagerImpl.runInBatchFilesMode(PsiManagerImpl.java:451)
@francislavoie
francislavoie / tabkey.js
Last active July 5, 2021 19:29
Violentmonkey: Tab key support for caddy.community
// ==UserScript==
// @name Tab key - caddy.community
// @namespace Violentmonkey Scripts
// @match https://caddy.community/*
// @grant none
// @version 1.0
// @author -
// @description 5/21/2020, 8:04:50 AM
// ==/UserScript==
// Set up the observer on DOM load

Keybase proof

I hereby claim:

  • I am francislavoie on github.
  • I am lavofr (https://keybase.io/lavofr) on keybase.
  • I have a public key ASBYVhDfPLnrpjrvdEoeMnmBLQ7UqmJv3HhbGxOXximMLAo

To claim this, I am signing this object: