.LOG updates
-
windows NOTEPAD, writes DATE and TIME each time file is updated when includes .LOG like first line into a file.
NOTEPAD++ would be nice to include it too, does not ?
-
@Clemente-Rodriguez said in .LOG updates:
windows NOTEPAD, writes DATE and TIME each time file is updated when includes .LOG like first line into a file.
I had never heard of that feature. I knew that it had the F5 = Edit > Time/Date to manually insert it.
NOTEPAD++ would be nice to include it too, does not ?
personally, I don’t have a need for it, though I can see why some people might like it. If you were willing to install the PythonScript plugin, then it wouldn’t be too hard to come up with a script that could be automatically run when you start Notepad++; it would run a function every time a file was opened, and if it starts with
.LOG
as the first line, it would then append the date at the end of the file. If you’re not interested in using the PythonScript plugin, I won’t bother explaining the details, but if you’d like that, let us know, and I or one of the other PythonScript afficionados could probably hack it together in a reasonably short amount of time. -
-
After I and @rdipardo had both separately confirmed that MS notepad.exe really does have that feature, I decided it was worth the effort to write the script, even if the original poster never comes back to ask for it.
Installation instructions
- see full instructions in our FAQ
https://community.notepad-plus-plus.org/topic/23039/faq-desk-how-to-install-and-run-a-script-in-pythonscript - save the script below as
DotLogTimestamp.py
in the PythonScript user-scripts directory (usually%AppData%\Notepad++\Plugins\Config\PythonScript\Scripts\
) - if you want this feature active every time you run Notepad++:
- Plugins > Python Script > Configuration: set Initialisation to
ATSTARTUP
- As the FAQ mentions, add the following lines to the user
startup.py
import DotLogTimestamp _DLTS = DotLogTimestamp.DLTS()
- Plugins > Python Script > Configuration: set Initialisation to
script:
DotLogTimestamp.py
# encoding=utf-8 """in response to https://community.notepad-plus-plus.org/topic/24650/ - Call this from startup.py using import DotLogTimestamp _DLTS = DotLogTimestamp.DLTS() - Make sure to set Plugins > PythonScript > Configuration > Initialisation to "ATSTARTUP" instead of "LAZY" - installation instructions: see https://community.notepad-plus-plus.org/topic/23039/faq-desk-how-to-install-and-run-a-script-in-pythonscript """ from Npp import editor,notepad,console,NOTIFICATION from datetime import datetime class DLTS(object): def __init__(self): console.write("Registered DotLogTimestamp.py callbacks\n") notepad.callback(self.fileopened_callback, [NOTIFICATION.FILEOPENED]) notepad.callback(self.bufferactivated_callback, [NOTIFICATION.BUFFERACTIVATED]) self.active = True self.bufferIDs = [] def toggle(self): self.active = not self.active console.write("DotLogTimestamp.py callbacks are {}\n".format('active' if self.active else 'inactive')) def fileopened_callback(self, args): if self.active: self.bufferIDs.append(args['bufferID']) def bufferactivated_callback(self, args): if self.active: if args['bufferID'] in self.bufferIDs: line = editor.getLine(0).strip() if line[0:4] == ".LOG": editor.appendText("{}\n".format(datetime.now().strftime("%Y-%b-%d %H:%M:%S"))) self.bufferIDs.remove(args['bufferID']) if __name__ == '__main__': try: _DLTS.toggle() except NameError: _DLTS = DLTS()
- see full instructions in our FAQ
-