Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

P: SDK: LrLogger adds extra "\r" to logged new lines on Windows

LEGEND ,
Sep 23, 2025 Sep 23, 2025

LrLogger adds an extra "\r" to each "\r\n" contained in logged strings on Windows. Tested on LR 14.5.1.

 

1. Save the attached file "logger-bug.txt" to the LR Scripts folder.  That script contains:

logger = import "LrLogger" ("MyLog")
logger:enable ("logfile")
logger:info ("line 1\r\nline 2\r\n")

 

2. Restart LR and execute the script.

 

3. Observe that %LOCALAPPDATA%\Adobe\Lightroom\Logs\LrClassicLogs\MyLog.log contains "line 1\r\r\nline 2\r\r\n" (incorrect) instead of "line 1\r\nline 2\r\n":

$ od -c MyLog.log 
0000000    0   9   /   2   3   /   2   0   2   5       1   6   :   4   9
0000020    :   4   4       I   N   F   O  \t   l   i   n   e       1  \r
0000040   \r  \n   l   i   n   e       2  \r  \r  \n  \0  \r  \n        

 

Bug Investigating
TOPICS
SDK
140
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Pinned Reply

Adobe Employee , Sep 24, 2025 Sep 24, 2025

Thanks @johnrellis  I will get this logged with the team.

Status Investigating
Translate
5 Comments
Participant ,
Sep 14, 2025 Sep 14, 2025

While reading a log file from a Python program I noticed that LrFileUtils.readFile adds "CR" character for every new line "CRLF" in Windows. 

In the sample script below I compare "LrFileUtils.readFile" with "io"

 

Is this normal or is this a bug?

 

File contents

line 1
line 2
line 3

 

To reproduce I use this small script

local LrDialogs         = import "LrDialogs"
local LrFunctionContext = import "LrFunctionContext"
local LrFileUtils       = import "LrFileUtils"

local JSON              = require "JSON"
local inspect           = require "inspect"

local logFilename       = 'TestReadFile'
local myLogger          = import 'LrLogger' (logFilename)
myLogger:enable("logfile")

local filePath = "D:/Temp/file.txt"

local function readJsonFile(path)
    local content
    local file = io.open(path, "r")

    if file then
        content = file:read("*all")
        file:close()
    else
        myLogger:info("Error opening file.")
    end

    return content
end

local function writeFile(content)
    local file = io.open(filePath, "w")
    if file then
        file:write(content)
        file:close()
        myLogger:info("String written to file successfully.")
    else
        myLogger:info("Error opening file.")
    end
end

local function main(context)
    local text = "line 1\nline 2\nline 3\n"
    writeFile(text)

    -- Open file file LrFileUtils.readFile( path )
    local contents = LrFileUtils.readFile(filePath)
    myLogger:info("File contents from LrFileUtils.readFile", contents)

    contents = readJsonFile(filePath)
    myLogger:info("File contents from io", contents)
end

LrFunctionContext.postAsyncTaskWithContext("Start culling", function(context)
    LrDialogs.attachErrorDialogToFunctionContext(context)
    main(context)
end)

In Windows using Notepad++ this is how the file look like:

File.txt

LightroomStatistics_0-1757918839539.png

Lightroom logger file

LightroomStatistics_1-1757918925310.png

 

Translate
Report
LEGEND ,
Sep 23, 2025 Sep 23, 2025
Translate
Report
LEGEND ,
Sep 23, 2025 Sep 23, 2025
Translate
Report
Adobe Employee ,
Sep 24, 2025 Sep 24, 2025

Thanks @johnrellis  I will get this logged with the team.

Rikk Flohr: Adobe Photography Org
Status Investigating
Translate
Report
Participant ,
Sep 25, 2025 Sep 25, 2025
LATEST

Great that you figured out that is was in the LrLogs and not in the LrFileUtils module.

Translate
Report