refactor: normalize log message grammar and capitalization

Problem: Log messages used inconsistent capitalization, punctuation,
and phrasing — some started lowercase, some omitted periods, "Pending"
was used instead of "task", and sync backend errors used ad-hoc
formatting.

Solution: Apply sentence case after backend prefixes, add trailing
periods to complete sentences, rename "Pending" to "task", use
`'Failed to <verb> <noun>: '` pattern for operation errors, and
pluralize "Archived N task(s)" correctly.
This commit is contained in:
Barrett Ruth 2026-03-06 18:37:02 -05:00
parent 874ff381f9
commit ca18574756
5 changed files with 28 additions and 28 deletions

View file

@ -173,7 +173,7 @@ function M.push()
oauth.with_token(oauth.google_client, 'gcal', function(access_token)
local calendars, cal_err = get_all_calendars(access_token)
if cal_err or not calendars then
log.error(cal_err or 'failed to fetch calendars')
log.error(cal_err or 'Failed to fetch calendars.')
return
end
@ -199,7 +199,7 @@ function M.push()
local del_err =
delete_event(access_token, cal_id --[[@as string]], event_id --[[@as string]])
if del_err then
log.warn('gcal delete failed: ' .. del_err)
log.warn('Failed to delete calendar event: ' .. del_err)
failed = failed + 1
else
unlink_remote(task, extra, now_ts)
@ -217,7 +217,7 @@ function M.push()
if event_id and cal_id then
local upd_err = update_event(access_token, cal_id, event_id, task)
if upd_err then
log.warn('gcal update failed: ' .. upd_err)
log.warn('Failed to update calendar event: ' .. upd_err)
failed = failed + 1
else
updated = updated + 1
@ -225,12 +225,12 @@ function M.push()
else
local lid, lid_err = find_or_create_calendar(access_token, cat, calendars)
if lid_err or not lid then
log.warn('gcal calendar failed: ' .. (lid_err or 'unknown'))
log.warn('Failed to create calendar: ' .. (lid_err or 'unknown'))
failed = failed + 1
else
local new_id, create_err = create_event(access_token, lid, task)
if create_err then
log.warn('gcal create failed: ' .. create_err)
log.warn('Failed to create calendar event: ' .. create_err)
failed = failed + 1
elseif new_id then
if not task._extra then

View file

@ -281,7 +281,7 @@ local function push_pass(access_token, tasklists, s, now_ts, by_gtasks_id)
if allow_remote_delete() then
local err = delete_gtask(access_token, list_id, gtid)
if err then
log.warn('gtasks delete failed: ' .. err)
log.warn('Failed to delete remote task: ' .. err)
failed = failed + 1
else
unlink_remote(task, now_ts)
@ -300,7 +300,7 @@ local function push_pass(access_token, tasklists, s, now_ts, by_gtasks_id)
if not synced_at or task.modified > synced_at then
local err = update_gtask(access_token, list_id, gtid, task_to_gtask(task))
if err then
log.warn('gtasks update failed: ' .. err)
log.warn('Failed to update remote task: ' .. err)
failed = failed + 1
else
task._extra = task._extra or {}
@ -314,7 +314,7 @@ local function push_pass(access_token, tasklists, s, now_ts, by_gtasks_id)
if not err and lid then
local new_id, create_err = create_gtask(access_token, lid, task_to_gtask(task))
if create_err then
log.warn('gtasks create failed: ' .. create_err)
log.warn('Failed to create remote task: ' .. create_err)
failed = failed + 1
elseif new_id then
if not task._extra then
@ -353,7 +353,7 @@ local function pull_pass(access_token, tasklists, s, now_ts, by_gtasks_id)
for list_name, list_id in pairs(tasklists) do
local items, err = list_gtasks(access_token, list_id)
if err then
log.warn('error fetching list ' .. list_name .. ': ' .. err)
log.warn('Failed to fetch task list "' .. list_name .. '": ' .. err)
failed = failed + 1
else
fetched_list_ids[list_id] = true
@ -428,7 +428,7 @@ end
local function sync_setup(access_token)
local tasklists, tl_err = get_all_tasklists(access_token)
if tl_err or not tasklists then
log.error(tl_err or 'failed to fetch task lists')
log.error(tl_err or 'Failed to fetch task lists.')
return nil, nil, nil
end
local s = require('pending').store()

View file

@ -57,7 +57,7 @@ end
---@param callback fun(access_token: string): nil
function M.with_token(client, name, callback)
if _sync_in_flight then
require('pending.log').warn(name .. ': sync operation in progress — please wait')
require('pending.log').warn(name .. ': Sync already in progress — please wait.')
return
end
_sync_in_flight = true
@ -65,7 +65,7 @@ function M.with_token(client, name, callback)
local token = client:get_access_token()
if not token then
_sync_in_flight = false
require('pending.log').warn(name .. ': not authenticated — run :Pending auth')
require('pending.log').warn(name .. ': Not authenticated — run :Pending auth.')
return
end
local ok, err = pcall(callback, token)
@ -279,7 +279,7 @@ function OAuthClient:get_access_token()
if now - obtained > expires - 60 then
tokens = self:refresh_access_token(creds, tokens)
if not tokens then
log.error(self.name .. ': token refresh failed — re-authenticating...')
log.error(self.name .. ': Token refresh failed — re-authenticating...')
return nil
end
end
@ -364,10 +364,10 @@ function OAuthClient:setup()
local path = vim.fn.stdpath('data') .. '/pending/google_credentials.json'
local ok = M.save_json_file(path, { client_id = id, client_secret = secret })
if not ok then
log.error(self.name .. ': failed to save credentials')
log.error(self.name .. ': Failed to save credentials.')
return
end
log.info(self.name .. ': credentials saved, starting authorization...')
log.info(self.name .. ': Credentials saved, starting authorization...')
self:auth()
end)
end
@ -382,7 +382,7 @@ function OAuthClient:auth(on_complete)
local creds = self:resolve_credentials()
if creds.client_id == BUNDLED_CLIENT_ID then
log.error(self.name .. ': no credentials configured — run :Pending auth')
log.error(self.name .. ': No credentials configured — run :Pending auth.')
return
end
local port = self.port
@ -433,7 +433,7 @@ function OAuthClient:auth(on_complete)
local bind_ok, bind_err = pcall(server.bind, server, '127.0.0.1', port)
if not bind_ok or bind_err == nil then
close_server()
log.error(self.name .. ': port ' .. port .. ' already in use — try again in a moment')
log.error(self.name .. ': Port ' .. port .. ' already in use — try again in a moment.')
return
end
@ -526,7 +526,7 @@ function OAuthClient:_exchange_code(creds, code, code_verifier, port, on_complet
decoded.obtained_at = os.time()
self:save_tokens(decoded)
log.info(self.name .. ' authorized successfully.')
log.info(self.name .. ': Authorized successfully.')
if on_complete then
on_complete()
end