Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/logger #120 #125

Merged
merged 15 commits into from
Feb 6, 2024
Merged

Feature/logger #120 #125

merged 15 commits into from
Feb 6, 2024

Conversation

fdodino
Copy link
Contributor

@fdodino fdodino commented Jan 26, 2024

Qué se incorpora

En este PR incorporamos el logger por archivo para loguear

  • ejecución del test runner: medimos el tiempo en milisegundos que tardaron en correr los tests, cuántos tests pasaron y cuántos fallaron, el stack trace de los tests que fallaron, el timestamp, entre otras cosas
  • ejecución de un programa (no game): el tiempo en ms que tardó en ejecutarse, el timestamp
  • ejecución de un programa (game): el tiempo que estuvo corriendo hasta que terminó o bien hasta que el usuario hizo Ctrl + C, Ctrl + D, kill -9 o lo que fuera.
  • errores que impiden levantar el REPL

No logueamos

  • inicialización del proyecto (wollok-init): tampoco se muy bien si tiene sentido, por ahí ver qué parámetros usaron, pero se que tarda poco y es una operación de única vez
  • el REPL: si bien podríamos loguear comandos que hayan tirado error, el riesgo de que el log se vuelva grande e incontrolable hace que prefiera por ahora no loguear nada. Si podemos acotar los eventos que nos interesan los agregamos.

De paso, saniticé el stack trace que mostramos:

  • elimino el stack trace de líneas vacías
  • y en los programas los errores tenían una leyenda Derived from TypeScript stack porque forma parte del message y no del stack. Se la saqué.

Implementación

  • conservamos el logger de loglevel dado que usa chalk con caracteres especiales para mostrar colores, bold, italic, etc. en la terminal y eso se ve feucho en un archivo
  • quise en algún momento usar strip-ansi como biblioteca pero rompía el proyecto y la verdad es que el log por consola y el de archivo son bastante diferentes (en cuanto a verbosidad y a lo que muestran), así que tenemos dos por separado
  • también me traje el TimeMeasurer y lo adapté para poder medir performance del test runner y de los programas.

Muestra de cómo se loguea

Un test:

{
    "failures": [],
    "level": "info",
    "message": "🧪 Test runner executed matching testExample.\"test para pepita\" on /home/dodain/workspace/wollok-dev/wollok-workspace/demo/pruebita",
    "result": {
        "failed": 0,
        "ok": 2
    },
    "timeElapsed": 186,
    "timestamp": "2024-01-26T23:02:54.681Z"
}
{
    "failures": [
        {
            "error": [
                "wollok.lib.AssertionException: Expected <101> but found <100>",
                "  at testExample.\"test para pepita\".\"energia inicial de pepita\" [testExample.wtest:5]"
            ],
            "test": "testExample.\"test para pepita\".\"energia inicial de pepita\""
        }
    ],
    "level": "info",
    "message": "🧪 Test runner executed matching testExample.\"test para pepita\" on /home/dodain/workspace/wollok-dev/wollok-workspace/demo/pruebita",
    "result": {
        "failed": 1,
        "ok": 1
    },
    "timeElapsed": 221,
    "timestamp": "2024-01-26T23:03:09.295Z"
}

Un programa:

{
    "error": [
        "wollok.lang.MessageNotUnderstoodException: a Seed does not understand chachini()",
        "  at example.Bird.eat(food) [example.wlk:6]",
"  at main.pepe [main.wpgm:3]"
    ],
    "level": "info",
    "message": "🚀 Program executed main.pepe on /home/dodain/workspace/wollok-dev/wollok-workspace/demo/pruebita",
    "ok": false,
    "timeElapsed": 184,
    "timestamp": "2024-01-26T23:04:30.885Z"
}
{
    "level": "info",
    "message": "🚀 Program executed main.pepe on /home/dodain/workspace/wollok-dev/wollok-workspace/demo/pruebita",
    "ok": true,
    "timeElapsed": 171,
    "timestamp": "2024-01-26T23:05:07.013Z"
}

Copy link

codecov bot commented Jan 27, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (74d7a79) 84.68% compared to head (aca14ab) 85.63%.

❗ Current head aca14ab differs from pull request most recent head 8a09c3d. Consider uploading reports for the commit 8a09c3d to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #125      +/-   ##
==========================================
+ Coverage   84.68%   85.63%   +0.94%     
==========================================
  Files           7        9       +2     
  Lines         653      696      +43     
  Branches      158      161       +3     
==========================================
+ Hits          553      596      +43     
  Misses        100      100              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@fdodino fdodino marked this pull request as ready for review January 29, 2024 02:05
Copy link
Contributor

@ivojawer ivojawer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chetisimo! 📝🚀

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wooo no la tenia a esta magia de sinon 🔥 🔥

src/commands/test.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@PalumboN PalumboN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Qué groso Fer! Impecable laburo 👏 🚀 🤖

Dejé un pequeño comentario sobre qué cosas serían interesantes loguear respecto al uso del REPL. Quizá convenga levantar un issue y verlo después de hacer algunas pruebas.

src/commands/repl.ts Show resolved Hide resolved
@PalumboN PalumboN merged commit a256f99 into master Feb 6, 2024
1 check passed
@PalumboN PalumboN deleted the feature/logger-#120 branch February 6, 2024 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants