From 198353b2141f1e4438f9e63053e9a0e01c01023d Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Mon, 28 Jul 2025 13:56:56 +0200 Subject: [PATCH 1/2] refs #2537 log whether we are in ogLive or not --- CHANGELOG.md | 6 ++++++ linux/debian/changelog | 6 ++++++ src/VERSION | 2 +- src/opengnsys/linux/log.py | 7 ++++++- src/opengnsys/windows/log.py | 4 +++- 5 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f403eb..0ae1e1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [7.2.0] - 2025-07-28 + +### Added + +- Log whether we are in ogLive or not + ## [7.1.0] - 2025-07-24 ### Changed diff --git a/linux/debian/changelog b/linux/debian/changelog index 5e24879..439a510 100644 --- a/linux/debian/changelog +++ b/linux/debian/changelog @@ -1,3 +1,9 @@ +ogagent (7.2.0-1) stable; urgency=medium + + * Log whether we are in ogLive or not + + -- OpenGnsys developers Mon, 28 Jul 2025 13:55:28 +0200 + ogagent (7.1.0-1) stable; urgency=medium * Don't pass the "tag" parameter to CrearImagenGit diff --git a/src/VERSION b/src/VERSION index a3fcc71..0ee843c 100644 --- a/src/VERSION +++ b/src/VERSION @@ -1 +1 @@ -7.1.0 +7.2.0 diff --git a/src/opengnsys/linux/log.py b/src/opengnsys/linux/log.py index 934bfa9..77617d6 100644 --- a/src/opengnsys/linux/log.py +++ b/src/opengnsys/linux/log.py @@ -42,6 +42,8 @@ OTHER, DEBUG, INFO, WARN, ERROR, FATAL = (10000 * (x + 1) for x in range(6)) class LocalLogger(object): def __init__(self): + self.extra = { 'in_oglive': None } + # tempdir is different for "user application" and "service" # service wil get c:\windows\temp, while user will get c:\users\XXX\temp # Try to open logger at /var/log path @@ -77,11 +79,14 @@ class LocalLogger(object): self.logger = None def log(self, level, message): + if self.extra['in_oglive'] is None: + self.extra['in_oglive'] = os.path.exists ('/scripts/functions') + # Debug messages are logged to a file # our loglevels are 10000 (other), 20000 (debug), .... # logging levels are 10 (debug), 20 (info) # OTHER = logging.NOTSET - self.logger.log(int(level / 1000) - 10, message, stacklevel=4) + self.logger.log(int(level / 1000) - 10, message, stacklevel=4, extra=self.extra) def isWindows(self): return False diff --git a/src/opengnsys/windows/log.py b/src/opengnsys/windows/log.py index 05f81f3..5b322f4 100644 --- a/src/opengnsys/windows/log.py +++ b/src/opengnsys/windows/log.py @@ -44,6 +44,8 @@ OTHER, DEBUG, INFO, WARN, ERROR, FATAL = (10000 * (x + 1) for x in range(6)) class LocalLogger(object): def __init__(self): + self.extra = { 'in_oglive': False } + # tempdir is different for "user application" and "service" # service wil get c:\windows\temp, while user will get c:\users\XXX\appdata\local\temp @@ -71,7 +73,7 @@ class LocalLogger(object): # our loglevels are 10000 (other), 20000 (debug), .... # logging levels are 10 (debug), 20 (info) # OTHER = logging.NOTSET - self.logger.log(int(level / 1000 - 10), message, stacklevel=4) + self.logger.log(int(level / 1000 - 10), message, stacklevel=4, extra=self.extra) if level < INFO or self.serviceLogger is False: # Only information and above will be on event log return From c53be3f3ec955aca2d0c63b675d7957a4d97363b Mon Sep 17 00:00:00 2001 From: Natalia Serrano Date: Mon, 28 Jul 2025 15:17:40 +0200 Subject: [PATCH 2/2] refs #2537 log whether we are in ogLive or not --- src/opengnsys/linux/log.py | 4 ++-- src/opengnsys/windows/log.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/opengnsys/linux/log.py b/src/opengnsys/linux/log.py index 77617d6..0b447a3 100644 --- a/src/opengnsys/linux/log.py +++ b/src/opengnsys/linux/log.py @@ -53,13 +53,13 @@ class LocalLogger(object): for logDir in ('/var/log', os.path.expanduser('~'), tempfile.gettempdir()): try: fname1 = os.path.join (logDir, 'opengnsys.log') - fmt1 = logging.Formatter (fmt='%(levelname)s %(asctime)s (%(threadName)s) (%(funcName)s) %(message)s') + fmt1 = logging.Formatter (fmt='%(levelname)s %(asctime)s in_oglive=%(in_oglive)s (%(threadName)s) (%(funcName)s) %(message)s') fh1 = logging.FileHandler (filename=fname1, mode='a') fh1.setFormatter (fmt1) fh1.setLevel (logging.DEBUG) fname2 = os.path.join (logDir, 'opengnsys.json.log') - fmt2 = JsonFormatter ({"timestamp": "asctime", "severity": "levelname", "threadName": "threadName", "function": "funcName", "message": "message"}, time_format='%Y-%m-%d %H:%M:%S', msec_format='') + fmt2 = JsonFormatter ({"timestamp": "asctime", "severity": "levelname", "in_oglive": "in_oglive", "threadName": "threadName", "function": "funcName", "message": "message"}, time_format='%Y-%m-%d %H:%M:%S', msec_format='') fh2 = logging.FileHandler (filename=fname2, mode='a') fh2.setFormatter (fmt2) fh2.setLevel (logging.DEBUG) diff --git a/src/opengnsys/windows/log.py b/src/opengnsys/windows/log.py index 5b322f4..e146e8f 100644 --- a/src/opengnsys/windows/log.py +++ b/src/opengnsys/windows/log.py @@ -50,13 +50,13 @@ class LocalLogger(object): # service wil get c:\windows\temp, while user will get c:\users\XXX\appdata\local\temp fname1 = os.path.join (tempfile.gettempdir(), 'opengnsys.log') - fmt1 = logging.Formatter (fmt='%(levelname)s %(asctime)s (%(threadName)s) (%(funcName)s) %(message)s') + fmt1 = logging.Formatter (fmt='%(levelname)s %(asctime)s in_oglive=%(in_oglive)s (%(threadName)s) (%(funcName)s) %(message)s') fh1 = logging.FileHandler (filename=fname1, mode='a') fh1.setFormatter (fmt1) fh1.setLevel (logging.DEBUG) fname2 = os.path.join (tempfile.gettempdir(), 'opengnsys.json.log') - fmt2 = JsonFormatter ({"timestamp": "asctime", "severity": "levelname", "threadName": "threadName", "function": "funcName", "message": "message"}, time_format='%Y-%m-%d %H:%M:%S', msec_format='') + fmt2 = JsonFormatter ({"timestamp": "asctime", "severity": "levelname", "in_oglive": "in_oglive", "threadName": "threadName", "function": "funcName", "message": "message"}, time_format='%Y-%m-%d %H:%M:%S', msec_format='') fh2 = logging.FileHandler (filename=fname2, mode='a') fh2.setFormatter (fmt2) fh2.setLevel (logging.DEBUG)