title: TypeError: logging.log is not a function JavaScript Google Cloud Fuction
body: <p>I have searched and can not find anything on this issue.</p>
  
  <p>I have deployed a few Google Cloud functions written in JavaScript which  leverages the following function to report errors. The functions run successfully but I have been receiving the following error: </p>
  
  <blockquote>
    <p>TypeError: logging.log is not a function
        at reportError (/user_code/index.js:158:23)</p>
  </blockquote>
  
  <pre><code>const logging = require('@google-cloud/logging');
  </code></pre>
  
  <p>reportError function:</p>
  
  <pre><code>function reportError(err, context = {}) {
  
    const logName = 'errors';
    const log = logging.log(logName);
  
    // https://cloud.google.com/logging/docs/api/ref_v2beta1/rest/v2beta1/MonitoredResource
    const metadata = {
      resource: {
        type: 'cloud_function',
        labels: {function_name: process.env.FUNCTION_NAME},
      },
    };
  
    // https://cloud.google.com/error-reporting/reference/rest/v1beta1/ErrorEvent
    const errorEvent = {
      message: err.stack,
      serviceContext: {
        service: process.env.FUNCTION_NAME,
        resourceType: 'cloud_function',
      },
      context: context,
    };
  
    // Write the error log entry
    return new Promise((resolve, reject) =&gt; {
      log.write(log.entry(metadata, errorEvent), (error) =&gt; {
        if (error) {
         return reject(error);
        }
        return resolve();
      });
    });
  }
  // [END reporterror]
  </code></pre>