fix(sync): add backend name prefix to all OAuth log messages (#122)
* fix(sync): add backend name prefix to all OAuth log messages (#121) Problem: four log messages in `oauth.lua` lacked the `self.name` backend prefix, producing generic notifications instead of identifying which backend (`gcal`/`gtasks`) triggered the message. Solution: prepend `self.name .. ': '` to the four unprefixed messages and drop the hardcoded "Google" from the browser prompt since `self.name` already identifies the service. * fix(sync): canonicalize all log prefixes across sync backends (#121) Problem: log messages in `oauth.lua`, `gcal.lua`, `gtasks.lua`, and `s3.lua` were inconsistent — some lacked a backend prefix, others used sentence-case or bare error strings without identifying the source. Solution: prefix all user-facing log messages with their backend name (`gcal:`, `gtasks:`, `S3:`, `Google:`). Capitalize `S3` and `Google` display names. Normalize casing and separator style (em dash) across all sync log sites.
This commit is contained in:
parent
1eb2e49096
commit
914633235a
4 changed files with 44 additions and 44 deletions
|
|
@ -69,7 +69,7 @@ end
|
|||
local function create_bucket()
|
||||
local name = util.input({ prompt = 'S3 bucket name (pending.nvim): ' })
|
||||
if not name then
|
||||
log.info('s3: bucket creation cancelled')
|
||||
log.info('S3: bucket creation cancelled')
|
||||
return
|
||||
end
|
||||
if name == '' then
|
||||
|
|
@ -108,7 +108,7 @@ local function create_bucket()
|
|||
.. '" } }'
|
||||
)
|
||||
else
|
||||
log.error('s3: bucket creation failed — ' .. (result.stderr or 'unknown error'))
|
||||
log.error('S3: bucket creation failed — ' .. (result.stderr or 'unknown error'))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -120,13 +120,13 @@ function M.auth(args)
|
|||
if not input or input == '' then
|
||||
local s3cfg = get_config()
|
||||
if s3cfg and s3cfg.profile then
|
||||
log.info('s3: current profile: ' .. s3cfg.profile)
|
||||
log.info('S3: current profile: ' .. s3cfg.profile)
|
||||
else
|
||||
log.info('s3: no profile configured (using default)')
|
||||
log.info('S3: no profile configured (using default)')
|
||||
end
|
||||
return
|
||||
end
|
||||
log.info('s3: set profile in your config: sync = { s3 = { profile = "' .. input .. '" } }')
|
||||
log.info('S3: set profile in your config: sync = { s3 = { profile = "' .. input .. '" } }')
|
||||
end)
|
||||
return
|
||||
end
|
||||
|
|
@ -138,9 +138,9 @@ function M.auth(args)
|
|||
if result.code == 0 then
|
||||
local ok, data = pcall(vim.json.decode, result.stdout or '')
|
||||
if ok and data then
|
||||
log.info('s3: authenticated as ' .. (data.Arn or data.Account or 'unknown'))
|
||||
log.info('S3: authenticated as ' .. (data.Arn or data.Account or 'unknown'))
|
||||
else
|
||||
log.info('s3: credentials valid')
|
||||
log.info('S3: credentials valid')
|
||||
end
|
||||
local s3cfg = get_config()
|
||||
if not s3cfg or not s3cfg.bucket then
|
||||
|
|
@ -149,21 +149,21 @@ function M.auth(args)
|
|||
else
|
||||
local stderr = result.stderr or ''
|
||||
if stderr:find('SSO') or stderr:find('sso') then
|
||||
log.info('s3: SSO session expired — running login...')
|
||||
log.info('S3: SSO session expired — running login...')
|
||||
local login_cmd = base_cmd()
|
||||
vim.list_extend(login_cmd, { 'sso', 'login' })
|
||||
local login_result = util.system(login_cmd, { text = true })
|
||||
if login_result.code == 0 then
|
||||
log.info('s3: SSO login successful')
|
||||
log.info('S3: SSO login successful')
|
||||
else
|
||||
log.error('s3: SSO login failed — ' .. (login_result.stderr or ''))
|
||||
log.error('S3: SSO login failed — ' .. (login_result.stderr or ''))
|
||||
end
|
||||
elseif
|
||||
stderr:find('Unable to locate credentials') or stderr:find('NoCredentialProviders')
|
||||
then
|
||||
log.error('s3: no AWS credentials configured. See :h pending-s3')
|
||||
log.error('S3: no AWS credentials configured. See :h pending-s3')
|
||||
else
|
||||
log.error('s3: ' .. stderr)
|
||||
log.error('S3: ' .. stderr)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
|
@ -176,10 +176,10 @@ end
|
|||
|
||||
function M.push()
|
||||
util.async(function()
|
||||
util.with_guard('s3', function()
|
||||
util.with_guard('S3', function()
|
||||
local s3cfg = get_config()
|
||||
if not s3cfg or not s3cfg.bucket then
|
||||
log.error('s3: bucket is required. Set sync.s3.bucket in config.')
|
||||
log.error('S3: bucket is required. Set sync.s3.bucket in config.')
|
||||
return
|
||||
end
|
||||
local key = s3cfg.key or 'pending.json'
|
||||
|
|
@ -198,7 +198,7 @@ function M.push()
|
|||
|
||||
local f = io.open(s.path, 'r')
|
||||
if not f then
|
||||
log.error('s3: failed to read store file')
|
||||
log.error('S3: failed to read store file')
|
||||
return
|
||||
end
|
||||
local content = f:read('*a')
|
||||
|
|
@ -206,7 +206,7 @@ function M.push()
|
|||
|
||||
local tf = io.open(tmpfile, 'w')
|
||||
if not tf then
|
||||
log.error('s3: failed to create temp file')
|
||||
log.error('S3: failed to create temp file')
|
||||
return
|
||||
end
|
||||
tf:write(content)
|
||||
|
|
@ -218,22 +218,22 @@ function M.push()
|
|||
os.remove(tmpfile)
|
||||
|
||||
if result.code ~= 0 then
|
||||
log.error('s3: push failed — ' .. (result.stderr or 'unknown error'))
|
||||
log.error('S3: push failed — ' .. (result.stderr or 'unknown error'))
|
||||
return
|
||||
end
|
||||
|
||||
util.finish(s)
|
||||
log.info('s3: push uploaded to s3://' .. s3cfg.bucket .. '/' .. key)
|
||||
log.info('S3: push uploaded to s3://' .. s3cfg.bucket .. '/' .. key)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
function M.pull()
|
||||
util.async(function()
|
||||
util.with_guard('s3', function()
|
||||
util.with_guard('S3', function()
|
||||
local s3cfg = get_config()
|
||||
if not s3cfg or not s3cfg.bucket then
|
||||
log.error('s3: bucket is required. Set sync.s3.bucket in config.')
|
||||
log.error('S3: bucket is required. Set sync.s3.bucket in config.')
|
||||
return
|
||||
end
|
||||
local key = s3cfg.key or 'pending.json'
|
||||
|
|
@ -245,7 +245,7 @@ function M.pull()
|
|||
|
||||
if result.code ~= 0 then
|
||||
os.remove(tmpfile)
|
||||
log.error('s3: pull failed — ' .. (result.stderr or 'unknown error'))
|
||||
log.error('S3: pull failed — ' .. (result.stderr or 'unknown error'))
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -256,7 +256,7 @@ function M.pull()
|
|||
end)
|
||||
if not load_ok then
|
||||
os.remove(tmpfile)
|
||||
log.error('s3: pull failed — could not parse remote store')
|
||||
log.error('S3: pull failed — could not parse remote store')
|
||||
return
|
||||
end
|
||||
|
||||
|
|
@ -318,7 +318,7 @@ function M.pull()
|
|||
|
||||
os.remove(tmpfile)
|
||||
util.finish(s)
|
||||
log.info('s3: pull ' .. util.fmt_counts({
|
||||
log.info('S3: pull ' .. util.fmt_counts({
|
||||
{ created, 'added' },
|
||||
{ updated, 'updated' },
|
||||
{ unchanged, 'unchanged' },
|
||||
|
|
@ -329,10 +329,10 @@ end
|
|||
|
||||
function M.sync()
|
||||
util.async(function()
|
||||
util.with_guard('s3', function()
|
||||
util.with_guard('S3', function()
|
||||
local s3cfg = get_config()
|
||||
if not s3cfg or not s3cfg.bucket then
|
||||
log.error('s3: bucket is required. Set sync.s3.bucket in config.')
|
||||
log.error('S3: bucket is required. Set sync.s3.bucket in config.')
|
||||
return
|
||||
end
|
||||
local key = s3cfg.key or 'pending.json'
|
||||
|
|
@ -414,7 +414,7 @@ function M.sync()
|
|||
|
||||
local f = io.open(s.path, 'r')
|
||||
if not f then
|
||||
log.error('s3: sync failed — could not read store file')
|
||||
log.error('S3: sync failed — could not read store file')
|
||||
return
|
||||
end
|
||||
local content = f:read('*a')
|
||||
|
|
@ -423,7 +423,7 @@ function M.sync()
|
|||
local push_tmpfile = vim.fn.tempname() .. '.json'
|
||||
local tf = io.open(push_tmpfile, 'w')
|
||||
if not tf then
|
||||
log.error('s3: sync failed — could not create temp file')
|
||||
log.error('S3: sync failed — could not create temp file')
|
||||
return
|
||||
end
|
||||
tf:write(content)
|
||||
|
|
@ -435,13 +435,13 @@ function M.sync()
|
|||
os.remove(push_tmpfile)
|
||||
|
||||
if push_result.code ~= 0 then
|
||||
log.error('s3: sync push failed — ' .. (push_result.stderr or 'unknown error'))
|
||||
log.error('S3: sync push failed — ' .. (push_result.stderr or 'unknown error'))
|
||||
util.finish(s)
|
||||
return
|
||||
end
|
||||
|
||||
util.finish(s)
|
||||
log.info('s3: sync ' .. util.fmt_counts({
|
||||
log.info('S3: sync ' .. util.fmt_counts({
|
||||
{ created, 'added' },
|
||||
{ updated, 'updated' },
|
||||
}) .. ' | push uploaded')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue