GoogleCloudPlatform / node-red-contrib-google-cloud

Node-RED nodes for Google Cloud Platform
Apache License 2.0
90 stars 57 forks source link

Logging to Cloud Logging #92

Open kolban-google opened 3 years ago

kolban-google commented 3 years ago

The Node-RED runtime has the ability to generate log messages. By default, these are written to the console. There is documentation which shows that these messages can be written elsewhere ... what if we want to log to cloud logging?

Reviewing the docs, it seems that at the highest level we can code:

logging: {
   ...
   GCP_Cloud_Logging: {
      level: "info"
      handler: function(conf) {
         // Initialize
         return function(message) {
            // Log the message
         }
      }
   }
}

The message passed to the function includes:

The level codes appear to be:

See also:

Thoughts

After some consideration, I'm no longer seeing as much value in this feature as I may have initially thought. The original thinking was to write all the log records from Node-RED to their own Cloud Logging log. However I now am questioning the value of that. How will we distinguish one NR engine instance from another? How will we know which flow issued the message?