Skip to content

Commit

Permalink
Create monstro805:python-package-conda.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Armando Lopez Jr authored Dec 10, 2021
1 parent f4ecb13 commit e46546c
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions user/build-script/monstro805:python-package-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import format from "quick-format-unescaped";

function onLogData(obj) {}
function onLogMessage(level, msg, data) {
console[level](msg, data);
}

function log(state, level, ...args) {
let obj = typeof args[0] === "object" ? args.shift() : {};
const msg = args.length >= 2 ? format(args.shift(), args) : args[0];

if (typeof msg !== "undefined") {
obj.msg = msg;
}

// handle errors
if (obj instanceof Error) {
obj = {
msg: obj.stack,
...Object.entries(obj).reduce((result, [key, value]) => {
return { ...result, [key]: value };
}, {}),
};
}

if (obj.msg && (level !== "debug" || state.options.debug)) {
const { msg: message, ...data } = obj;
state.onLogMessage(level, message, data);
}

state.onLogData({ ...state.context, ...obj, level, time: Date.now() });
}

export function logger(octokit, { octoherd = {} }) {
const state = {
options: octoherd,
onLogData: octoherd.onLogData || onLogData,
onLogMessage: octoherd.onLogMessage || onLogMessage,
context: {},
};

return {
log: {
debug: log.bind(null, state, "debug"),
info: log.bind(null, state, "info"),
warn: log.bind(null, state, "warn"),
error: log.bind(null, state, "error"),
// Adds extra info ONLY to log files but not to stdout
setContext(context) {
state.context = context;
},
},
};
}

0 comments on commit e46546c

Please sign in to comment.