log and Debug
Scramjet Cloud Platform is constantly monitoring the user's Sequence, and producing log output for a Sequence which can be accessible. Details of each invoked Sequence can be viewed through different methods. More information on Scramjet's
object-logger .
-
SCP Console Panel > Space > Show logs > Download
-
For returnning the log through calling the
logger
method inside the main file. In order to be retrieved use
/instance/<Instance-id>/log API endpoint. The below example will provide a brief illustration.
- JavaScript
- TypeScript
- Python
import { ReadableApp } from "@scramjet/types";
const app: ReadableApp<string> = async function(_stream) {
// Write to a instance logger. first parameter could be any on the following list:
// Logger has the following log levels:
// - **debug**
// - **error**
// - **fatal**
// - **info**
// - **trace**
// - **warn**
this.logger.write("INFO", "this is info log");
return Promise.resolve("end");
};
export default app;
import { ReadableApp } from "@scramjet/types";
const app: ReadableApp<string> = async function(_stream) {
// Write to a instance logger. first parameter could be any on the following list:
// Logger has the following log levels:
// - **debug**
// - **error**
// - **fatal**
// - **info**
// - **trace**
// - **warn**
this.logger.write("INFO", "this is info log");
return Promise.resolve("end");
};
export default app;
import asyncio
async def run(context, input):
# your code here, you can also process an input stream
context.logger.debug('Debug log message')
context.logger.info('Info log message')
context.logger.warn('Warn log message')
await asyncio.sleep(10)
return output # return stream value
- For returning the log through calling the
Error
class inside the main file. In order to be retrieved through /instance/<Instance-id>/stderr API endpoint, or through CLI assi instance stderr <Instance-id>
. The below example will provide a brief illustration.
- JavaScript
- TypeScript
- Python
import { ReadableApp } from "@scramjet/types";
const app: ReadableApp<string> = async function(_stream) {
// This will write an error message to stderr
const err = new Error("The Sequence was not completed");
console.error(err);
return Promise.resolve("end");
};
export default app;
import { ReadableApp } from "@scramjet/types";
const app: ReadableApp<string> = async function(_stream) {
// This will write an error message to stderr
const err = new Error("The Sequence was not completed");
console.error(err);
return Promise.resolve("end");
};
export default app;
import sys
async def run(context, input):
# your code here, you can also process an input stream
sys.stderr.write("Error")
return output # return stream value
- For displaying the content a user can use
/instance/<Instance-id>/stdout API endpoint,
or through CLI as
si instance stdout <Instance-id>
. The below example will provide a brief illustration.
- JavaScript
- TypeScript
- Python
import { ReadableApp } from "@scramjet/types";