Skip to main content

Print Logs

log

1. Interface Description

Function: Log Reporting by Log Level

Interface declaration: log(data: Object): void

2. Input Parameters

FieldTypeRequiredDescription
-ObjectYesLog object

3. Response

None

4. Sample Code

const tcb = require('@cloudbase/node-sdk')
const app = tcb.init()
let logMsg = { name: 'luke', age: '25' } // msg must be an object

exports.main = async (event, context) => {
// Output log level
app.logger().log(logMsg)
}

warn

1. Interface Description

Function: Log Reporting by warn level

Interface declaration: warn(data: Object): void

2. Input Parameters

FieldTypeRequiredDescription
-ObjectYesLog object

3. Response

None

4. Sample Code

const tcb = require('@cloudbase/node-sdk')
const app = tcb.init()
let logMsg = { name: 'luke', age: '25' } // msg must be an object

exports.main = async (event, context) => {
// Output warn level
app.logger().warn(logMsg)
}

error

1. Interface Description

Function: Log Reporting by error level

Interface declaration: error(data: Object): void

2. Input Parameters

FieldTypeRequiredDescription
-ObjectYesLog object

3. Response

None

4. Sample Code

const tcb = require('@cloudbase/node-sdk')
const app = tcb.init()
let logMsg = { name: 'luke', age: '25' } // msg must be an object

exports.main = async (event, context) => {
// Output error level
app.logger().error(logMsg)
}

info

1. Interface Description

Function: Log Reporting by info level

Interface declaration: info(data: Object): void

2. Input Parameters

FieldTypeRequiredDescription
-ObjectYesLog object

3. Response

None

4. Sample Code

const tcb = require('@cloudbase/node-sdk')
const app = tcb.init()
let logMsg = { name: 'luke', age: '25' } // msg must be an object

exports.main = async (event, context) => {
// Output info level
app.logger().info(logMsg)
}