Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/elsbeth-geranium'
Browse files Browse the repository at this point in the history
  • Loading branch information
gtritchie committed Jan 13, 2023
2 parents 85e4cba + 828cdab commit 9b2a47a
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 120 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ properties([
artifactNumToKeepStr: '',
daysToKeepStr: '',
numToKeepStr: '100')),
parameters([string(name: 'RSTUDIO_VERSION_PATCH', defaultValue: '0', description: 'RStudio Patch Version'),
parameters([string(name: 'RSTUDIO_VERSION_PATCH', defaultValue: '1', description: 'RStudio Patch Version'),
string(name: 'SLACK_CHANNEL', defaultValue: '#ide-builds', description: 'Slack channel to publish build message.'),
string(name: 'OS_FILTER', defaultValue: '', description: 'Pattern to limit builds by matching OS'),
string(name: 'ARCH_FILTER', defaultValue: '', description: 'Pattern to limit builds by matching ARCH'),
Expand Down
25 changes: 0 additions & 25 deletions NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ used by these components are included below):
- winston (npm)
- i18next (npm)
- copy-webpack-plugin (npm)
- winston-daily-rotate-file
- node-system-fonts
- properties-reader (npm)
- json-schema-to-typescript (npm)
Expand Down Expand Up @@ -4479,30 +4478,6 @@ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

winston-daily-rotate-file (npm) License
----------------------------------------------------------------------
The MIT License (MIT)

Copyright (c) 2015 winstonjs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

node-system-fonts (npm) License
----------------------------------------------------------------------
MIT License
Expand Down
20 changes: 12 additions & 8 deletions package/win32/make-package.bat
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ if "%1" == "-h" goto :showhelp
if "%1" == "help" goto :showhelp
if "%1" == "/?" goto :showhelp

SETLOCAL ENABLEDELAYEDEXPANSION
for %%A in (%*) do (
if /I "%%A" == "clean" set CLEANBUILD=1
if /I "%%A" == "debug" set DEBUG_BUILD=1
if /I "%%A" == "desktop" set RSTUDIO_TARGET=Desktop
if /I "%%A" == "electron" set RSTUDIO_TARGET=Electron
if /I "%%A" == "multiarch" set MULTIARCH=1
if /I "%%A" == "nogwt" set BUILD_GWT=0
if /I "%%A" == "nozip" set NOZIP=1
if /I "%%A" == "quick" set QUICK=1
set KNOWN_ARG=0
if /I "%%A" == "clean" set CLEANBUILD=1 && set KNOWN_ARG=1
if /I "%%A" == "debug" set DEBUG_BUILD=1 && set KNOWN_ARG=1
if /I "%%A" == "desktop" set RSTUDIO_TARGET=Desktop && set KNOWN_ARG=1
if /I "%%A" == "electron" set RSTUDIO_TARGET=Electron && set KNOWN_ARG=1
if /I "%%A" == "multiarch" set MULTIARCH=1 && set KNOWN_ARG=1
if /I "%%A" == "nogwt" set BUILD_GWT=0 && set KNOWN_ARG=1
if /I "%%A" == "nozip" set NOZIP=1 && set KNOWN_ARG=1
if /I "%%A" == "quick" set QUICK=1 && set KNOWN_ARG=1

if "!KNOWN_ARG!" == "0" goto :showhelp
)

REM check for debug build
Expand Down
5 changes: 2 additions & 3 deletions src/cpp/diagnostics/DiagnosticsMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ void writeUserPrefs(std::ostream& ostr)

int main(int argc, char** argv)
{
core::log::setProgramId("rstudio-diagnostics");
core::system::initializeStderrLog("rstudio-diagnostics",
core::log::LogLevel::WARN);
// We intentionally avoid initializing logging as we don't want logging output from this
// executable getting injected into the diagnostics report

// ignore SIGPIPE
Error error = core::system::ignoreSignal(core::system::SigPipe);
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/r/R/Diagnostics.R
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ sensitive information before submitting your diagnostics report.
# detect release configurations
sysname <- Sys.info()[["sysname"]]
if (identical(sysname, "Darwin"))
"../../MacOS/diagnostics"
"../bin/diagnostics"
else if (identical(sysname, "Windows"))
"../bin/diagnostics.exe"
else
Expand Down
71 changes: 0 additions & 71 deletions src/node/desktop/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion src/node/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
"properties-reader": "2.2.0",
"uuid": "9.0.0",
"winston": "3.8.2",
"winston-daily-rotate-file": "4.7.1",
"winston-syslog": "2.7.0"
}
}
6 changes: 4 additions & 2 deletions src/node/desktop/src/core/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*
*/

import winston from 'winston';

import { coreState } from './core-state';

export interface Logger {
Expand All @@ -28,6 +26,8 @@ export interface Logger {
logDebug(message: string): void;
logDiagnostic(message: string): void;
logDiagnosticEnvVar(name: string): void;
closeLogFile(): void;
ensureTransport(): void;
}

export interface LogOptions {
Expand All @@ -54,6 +54,8 @@ export class NullLogger implements Logger {
logDebug(message: string): void {}
logDiagnostic(message: string): void {}
logDiagnosticEnvVar(name: string): void {}
closeLogFile(): void {}
ensureTransport(): void {}
}

/**
Expand Down
46 changes: 38 additions & 8 deletions src/node/desktop/src/core/winston-logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import { app } from 'electron';
import winston, { format } from 'winston';
import DailyRotateFile from 'winston-daily-rotate-file';
import { Syslog } from 'winston-syslog';
import { Console } from 'winston/lib/winston/transports';
import LogOptions from '../main/log-options';
Expand All @@ -31,6 +30,9 @@ const { combine, printf, timestamp, json } = winston.format;
export class WinstonLogger implements Logger {
logger: winston.Logger;

// track file transport so we can close it
fileTransport: winston.transports.FileTransportInstance | null = null;

constructor(logOptions: LogOptions) {
const level = this.readLogLevelOverride(logOptions.getLogLevel());
const format = logOptions.getLogMessageFormat() === 'pretty' ?
Expand All @@ -47,9 +49,11 @@ export class WinstonLogger implements Logger {
defaultMeta: { service: 'rdesktop'}
});

let consoleLogging = false;
let logTransport;
if (logOptions.getLoggerType() === 'stderr' || !app.isPackaged) {
if (logOptions.getLoggerType() === 'stderr') {
logTransport = new Console();
consoleLogging = true;
}

if (logOptions.getLoggerType() === 'syslog') {
Expand All @@ -65,12 +69,23 @@ export class WinstonLogger implements Logger {
}
}

this.logger.add(logTransport ?? new DailyRotateFile({
filename: `${logFile.getStem()}.%DATE%${logFile.getExtension()}`,
dirname: logFile.getParent().getAbsolutePath(),
datePattern: 'YYYY-MM-DD',
frequency: '1d',
}));
if (!logTransport) {
logTransport = new winston.transports.File({
filename: logFile.getAbsolutePath(),
tailable: true,
maxsize: 2000000, // TODO: use max-size from logging.conf (convert from mb to bytes)
maxFiles: 100 }); // TODO: use max-rotation from logging.conf

this.fileTransport = logTransport;
}

this.logger.add(logTransport);

// on dev builds, always log to console
if (!consoleLogging && !app.isPackaged) {
this.logger.add(new Console());
consoleLogging = true;
}

if (optionError) {
this.logErrorMessage(optionError);
Expand Down Expand Up @@ -140,6 +155,21 @@ export class WinstonLogger implements Logger {
}
}
}

closeLogFile(): void {
if (this.fileTransport) {
this.logger.remove(this.fileTransport);
this.fileTransport = null;
}
}

ensureTransport(): void {
// Winston emits warnings if there is no transport
if (this.logger.transports.length === 0) {
this.logger.add(new Console());
}
}

}

// removes `timestamp` key from json since we add `time` to match Qt log format
Expand Down
15 changes: 15 additions & 0 deletions src/node/desktop/src/main/session-launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ export class SessionLauncher {
this.showSplash = false;
}

// don't show splash screen if started using --run-diagnostics
if (appState().runDiagnostics) {
this.showSplash = false;
}

// must check showSplash before and after the timeout
// before to determine if the timeout is required
// after to determine if the main window is ready to show
Expand Down Expand Up @@ -237,6 +242,16 @@ export class SessionLauncher {
// pMainWindow_->connect(&activation(), &DesktopActivation::updateLicenseWarningBar,
// pMainWindow_, &MainWindow::onUpdateLicenseWarningBar);

// On Windows, we have to close the log file when running diagnostics or diagnostics.exe
// fails to inject the log contents into the diagnostics report due to access-denied due
// to file being in use by another process
if (process.platform === 'win32' && appState().runDiagnostics) {
logger().closeLogFile();

// winston logging package emits warnings if we don't have any registered transport
logger().ensureTransport();
}

// show the window (but don't if we are doing a --run-diagnostics)
if (!appState().runDiagnostics) {
finalPlatformInitialize(this.mainWindow);
Expand Down

0 comments on commit 9b2a47a

Please sign in to comment.