refactor: normalize log message grammar and capitalization (#89)
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:
parent
abf3e52277
commit
012bd9b043
5 changed files with 28 additions and 28 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue