Controlling logging in Avo Codegen
💡
Custom loggers are currently only supported in Swift, JavaScript and TypeScript. Reach out to us if you want access to custom loggers in your programming languages.
To get fine control over the logs you can provide a custom logger to Avo Codegen.
Notice the returned boolean, if you return true
Avo Codegen won't print the built-in logs.
Swift
class MyAvoLogger : AvoLogger {
func logDebug(env: AvoEnv, message: String) -> Bool {
NSLog("[debug] My avo logger: " + String(describing: env) + " " + message)
return true
}
func logWarn(env: AvoEnv, message: String) -> Bool {
NSLog("[warn] My avo logger: " + String(describing: env) + " " + message)
return false
}
func logError(env: AvoEnv, message: String) -> Bool {
NSLog("[error] My avo logger: " + String(describing: env) + " " + message)
return false
}
}
Avo.initAvo(...)
Avo.avoLogger = MyAvoLogger()
JavaScript
const avoLogger = {
logDebug: (env, message) => {
console.log("Avo Custom Logger Here!", message, env)
return true
},
logWarn: (env, message) => {
console.log("Avo Custom Logger Here!", message, env)
return true
},
logError: (env, message) => {
console.log("Avo Custom Logger Here!", message, env)
return true
}
};
Avo.initAvo(
{ env: env.DEV, ..., avoLogger: avoLogger },
...
);
TypeScript
const avoLogger = {
logDebug: (env: AvoEnv, message: string): boolean => {
console.log("Avo Custom Logger Here!", message, env)
return true
},
logWarn: (env: AvoEnv, message: string): boolean => {
console.log("Avo Custom Logger Here!", message, env)
return true
},
logError: (env: AvoEnv, message: string): boolean => {
console.log("Avo Custom Logger Here!", message, env)
return true
}
};
Avo.initAvo(
{ env: env.DEV, ..., avoLogger: avoLogger },
...
);