export function log(scope, message, data) {
  if (!isDevelopment()) return;
  const suffix = data === undefined ? '' : ` ${format(data)}`;
  console.log(`[PhotoRenamer:${scope}] ${message}${suffix}`);
}

export function error(scope, message, err) {
  if (!isDevelopment()) return;
  console.error(`[PhotoRenamer:${scope}] ${message}`, err);
}

function isDevelopment() {
  return window.api?.env?.logEnabled === true;
}

function format(data) {
  try {
    return JSON.stringify(data);
  } catch {
    return String(data);
  }
}
