Skip to content

adding some console.log to Nodebb

Solved Customisation
  • I’m trying some code small addition to NodeBB.
    for debugging purposed where do any outputs from console.log() go?

    Usually, when I run my own stand-alone node code it ‘hangs the screen’ until Ctrl-X out of it, hence you can see console.logs
    But as nodeBB runs as a service in the background, you dont see console.log output on the screen

  • @eeeee output from console.log will be in the console tab of the browser when your press F12 to access the developer tools.

  • phenomlabundefined phenomlab has marked this topic as solved on
  • @phenomlab
    oh, surely only javascript console.log goes to front end, Im meaning using console.log in server side node code.
    What I want is a note to myself on server, not viewable front end.
    for example Ive added some code which doesnt work, and I want to log (somewhere)
    “Reached this code”
    x=10
    etc
    So I want to console log to a server side file I can go and read to help me debug.
    Is there a nodebb log already in use I can write to?
    I tried making my own txt file as using fs.writeFile and that did not work, but thinking some built in console.log command would be simpler

  • @eeeee if you’re using the console, you could try

    node app.js > app.log 2>&1

    This would redirect stdout to a file named app.log and redirect stderr to stdout.

    I’m not sure about standard logging under NodeBB, but there is an error log located at logs/error.log.

    Failing that, you could always stop the NodeBB service then use ./nodebb dev from the console which would then provide debug output.


Did this solution help you?
Did you find the suggested solution useful? Why not buy me a coffee? It's a nice gesture, and a great way to show your appreciation 💗

  • Page control arrows for PWA

    Solved Customisation
    27
    25 Votes
    27 Posts
    339 Views

    @crazycells it is, yes - I think I’ll leave it as there is no specific PWA CSS classes I know of. Well, you could use something like the below, but this means multiple CSS files for different operating systems.

    /** * Determine the mobile operating system. * This function returns one of 'iOS', 'Android', 'Windows Phone', or 'unknown'. * * @returns {String} */ function getMobileOperatingSystem() { var userAgent = navigator.userAgent || navigator.vendor || window.opera; // Windows Phone must come first because its UA also contains "Android" if (/windows phone/i.test(userAgent)) { return "Windows Phone"; } if (/android/i.test(userAgent)) { return "Android"; } if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) { return "iOS"; } return "unknown"; // return “Android” - one should either handle the unknown or fallback to a specific platform, let’s say Android }

    Once you’re in that rabbit hole, it’s impossible to get out of it.

  • nodebb error logs

    Bugs
    6
    4 Votes
    6 Posts
    175 Views

    I just wanted to ask because I don’t have much knowledge about the new installation.
    Thank you for the explanatory answer.

  • Forum Icons NodeBB

    Solved Customisation
    13
    0 Votes
    13 Posts
    800 Views

    @cagatay That matches what I see

    4f0f858d-9812-42b1-9f61-ffb13d31dccd-image.png

  • NodeBB Theme/Skin Switcher

    Solved Customisation
    38
    7 Votes
    38 Posts
    2k Views

    @Teemberland great spot ! You should create a PR for that so they can include it in the official repository.

    Just be aware that any subsequent releases will overwrite your fix without the PR.

  • 4 Votes
    8 Posts
    529 Views

    @crazycells hmm. Good point. I actually use my own version of the dark mode plugin, so not entirely sure. However, I think the CSS is probably the same. I’m not at my PC currently but can check and advise later.

  • 3 Votes
    6 Posts
    991 Views

    @phenomlab

    haha!!
    You are crazy. In a good way, of course 🙂

    It’s a way of saying you’re awesome !

  • Social icon (Nodebb)

    Solved Customisation
    7
    0 Votes
    7 Posts
    916 Views

    @phenomlab said in Social icon (Nodebb):

    @jac I just tested my theory around using the OG image, and according to the Twitter card validator, it works fine

    73e805e1-997b-41bf-9259-51c5052ca8fc-image.png

    fixed 🙂

  • 3 Votes
    20 Posts
    978 Views

    @jac Exactly. Hard point to argue.