SerialLogHander no Log object defined

I have #include "Particle.h" and SerialLogHander logHandler(LOG_LEVEL_INFO); in my code; however, I get the following error when particle compile photon2 in my project directory:

src/christmastree24.cpp:39:1: error: 'Log' does not name a type; did you mean 'log'?
   39 | Log.info("GatorDot init");
      | ^~~
      | log

Log does not appear to be defined in my scope.

Does your project have a project.properties file in the top level directory? (It can be empty.)

Did you Particle: Configure Project for Device?

These two things are necessary for Intellisense to be activated, which is what causes the edit-time warnings.

The Particle CLI compile command separate and its settings are not used for Intellisense.

I am using particle-cli.

Does your project have a project.properties file in the top level directory? (It can be empty.)

Yes:
particle.properties

name=christmastree24
#assetOtaDir=assets
dependencies.gatordot=0.1.0

Did you Particle: Configure Project for Device?
I am not sure. I created it with particle project create

That error came from compile time (via project compile photon2).

Sorry, I misunderstood your original issue. Could you share more of the .cpp file?

UPDATE

Through some experimentation, I figured out that Log is not defined prior to setup().

I have also learned that Log.info() calls in setup are not seen on the monitor as it doesn't start logging until ~2400 ms.

Correct, Log is a statement you can add inside functions - like setup() or loop().

If you want to get all logs from the start, you can add this inside setup(), right at the beginning:

    waitFor(Serial.isConnected, 5000);
    delay(1000);

Best,

1 Like