Logger
Set different levels to control the log output level
JavaScriptOther
Set different levels to control the log output level
Parameters
| Name | Default | What it controls |
|---|---|---|
| level | 0 | Log levels: Debug | Info | Warning | Error |
Source JavaScript
//var COLOR_ERROR = "#FF0000"
//var COLOR_WARN = "#FF0000"
//var COLOR_INFO = "#0000FF"
//var COLOR_DEBUG = "#000000"
var LEVER_PATTERN = {
DEBUG: 0,
INFO: 1,
WARNING: 2,
ERROR: 3
}
//var loggerLever = [LEVER_PATTERN.DEBUG, LEVER_PATTERN.INFO, LEVER_PATTERN.WARNING, LEVER_PATTERN.ERROR][level]
$.Error = function(msg) {
Log('[ERR] ', msg, '#FF0000')
}
$.Warn = function(msg) {
if(level <= LEVER_PATTERN.WARNING) {
Log('[WAR] ', msg, '#FF0000')
}
}
$.Info = function(msg) {
if(level <= LEVER_PATTERN.INFO) {
Log('[INF] ', msg, '#0000FF')
}
}
$.Debug = function(msg) {
if(level <= LEVER_PATTERN.DEBUG) {
Log('[DBG] ', msg, '#000000')
}
}
function main() {
$.Error('this is error')
$.Warn('this is warn')
$.Info('this is info')
$.Debug('this is debug')
}
Published by fmzero on the FMZ strategy square · last modified 2020-01-20. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.
Build this with AgenKit
A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/Logger.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- Get tests, backtest, risk controls and a paper-trading switch
Understand it first
Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.