11local renderer = require (" image/renderer" )
22local utils = require (" image/utils" )
3+ local log = require (" image/utils/logger" ).within (" image" )
34
45-- { ["buf:row:col"]: { id, height } }
56--- @type table<string , { id : number , height : number } >
@@ -55,7 +56,7 @@ function Image:render(geometry)
5556
5657 -- track last_modified and wipe cache
5758 local current_last_modified = vim .fn .getftime (self .original_path )
58- -- utils .debug(("timestamp: %s, last_modified: %s"):format(current_last_modified, self.last_modified))
59+ log .debug ((" timestamp: %s, last_modified: %s" ):format (current_last_modified , self .last_modified ))
5960 if self .last_modified ~= current_last_modified then
6061 self .last_modified = current_last_modified
6162 self .resize_hash = nil
@@ -77,18 +78,18 @@ function Image:render(geometry)
7778 renderer .clear_cache_for_path (self .original_path )
7879 end
7980
80- -- utils .debug(("---------------- %s ----------------"):format(self.id))
81+ log .debug ((" ---------------- %s ----------------" ):format (self .id ))
8182 local was_rendered = renderer .render (self )
8283
83- -- utils .debug(
84- -- ("[image] success: %s x: %s, y: %s, width: %s, height: %s"):format(
85- -- was_rendered,
86- -- self.geometry.x,
87- -- self.geometry.y,
88- -- self.geometry.width,
89- -- self.geometry.height
90- -- )
91- -- )
84+ log .debug (
85+ ( " success: %s x: %s, y: %s, width: %s, height: %s" ):format (
86+ was_rendered ,
87+ self .geometry .x ,
88+ self .geometry .y ,
89+ self .geometry .width ,
90+ self .geometry .height
91+ )
92+ )
9293
9394 -- clear if already rendered but rendering this should be prevented
9495 if self .is_rendered and not was_rendered then
@@ -112,7 +113,7 @@ function Image:render(geometry)
112113
113114 if not has_up_to_date_extmark then
114115 if previous_extmark ~= nil then
115- -- utils .debug(("(image.render) clearing extmark %s"):format(previous_extmark.id))
116+ log .debug ((" clearing extmark %s" ):format (previous_extmark .id ))
116117 vim .api .nvim_buf_del_extmark (self .buffer , self .global_state .extmarks_namespace , previous_extmark .id )
117118 buf_extmark_map [extmark_key ] = nil
118119 end
@@ -128,7 +129,7 @@ function Image:render(geometry)
128129 extmark_opts .virt_lines = filler
129130 end
130131
131- -- utils .debug(("(image.render) creating extmark %s"):format(self.internal_id))
132+ log .debug ((" creating extmark %s" ):format (self .internal_id ))
132133 local extmark_row = math.max (row or 0 , 0 )
133134 local extmark_col = math.max (col or 0 , 0 )
134135 local ok , extmark_id = pcall (
165166
166167--- @param shallow ? boolean
167168function Image :clear (shallow )
168- -- utils .debug(("[image] clear %s, shallow: %s"):format(self.id, shallow))
169+ log .debug ((" clear %s, shallow: %s" ):format (self .id , shallow ))
169170 self .global_state .backend .clear (self .id , shallow or false )
170171
171172 self .rendered_geometry = {
@@ -262,7 +263,7 @@ local from_file = function(path, options, state)
262263
263264 -- bail if not an image
264265 if not utils .magic .is_image (absolute_original_path ) then
265- -- utils.debug (("image.nvim: not an image: %s"):format(absolute_original_path))
266+ log . info ((" not an image: %s" ):format (absolute_original_path ))
266267 return nil
267268 end
268269
@@ -302,7 +303,7 @@ local from_file = function(path, options, state)
302303 namespace = opts .namespace or nil ,
303304 last_modified = vim .fn .getftime (absolute_original_path ),
304305 }, state )
305- -- utils .debug(("image.nvim: cloned image %s from %s"):format(clone.id, instance.id))
306+ log .debug ((" cloned image %s from %s" ):format (clone .id , instance .id ))
306307 return clone
307308 end
308309 end
@@ -386,7 +387,7 @@ local from_url = function(url, options, callback, state)
386387 }, function (code , signal )
387388 if code ~= 0 then
388389 if state .options .ignore_download_error then
389- utils . debug ( " image: curl errored while downloading " .. url , {
390+ log . error ( " curl errored while downloading " .. url , {
390391 code = code ,
391392 signal = signal ,
392393 })
@@ -402,7 +403,7 @@ local from_url = function(url, options, callback, state)
402403
403404 vim .loop .read_start (stdout , function (err , data )
404405 assert (not err , err )
405- if not data then utils . debug ( " image: downloaded " .. url .. " to " .. tmp_path ) end
406+ if not data then log . info ( " downloaded " .. url .. " to " .. tmp_path ) end
406407 state .remote_cache [url ] = tmp_path
407408
408409 vim .defer_fn (function ()
0 commit comments