Skip to main content
johnrellis
Legend
Sep 15, 2025 6:52 AM UTC
Needs More Info

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

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        

 

5 replies

Inspiring
Sep 25, 2025 1:52 PM UTC

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

Translate
Rikk Flohr-Retired
Adobe Employee
Sep 24, 2025 12:33 PM UTC

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

Translate
Rikk Flohr: Adobe Photography Org
Inspiring
Sep 15, 2025 6:52 AM UTC

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

Lightroom logger file

 

Translate
johnrellis
Legend
Sep 23, 2025 11:58 PM UTC
johnrellis
Legend
Sep 23, 2025 11:59 PM UTC