Keeping a Daily Log in Evernote

For the last few years I have been keeping a daily log of events and information in a daily log using Evernote. In this article I will describe how I use a daily log in Evernote and the code I used to build a journal template.

Using a Daily Log

My daily log is a place where I record notes on programming, applications, machine, and other information. Updates to applications, error reports, meeting notes, code snippets, and links to articles I would like to read later are all kept in my log.

I record events by the date which gives some order to this jumble of information. Also when tracking errors down it is good to have a date associated with their appearance.
Despite the dated entries I don’t really use it as a calendar or planner. However on occasion I will put an entry in a future date about some deadline or task to perform. But mostly it is for a record of what happened when on what project, program, or machine.

I keep one log per year. Although you can search over all your notes in Evernote I find it useful and faster to search within a note if I know the data or event was in a particular year. Also when you first bring up a note you are at January 1, so you have to page down to the current date to start a new entry for the current day.

Advantages of Evernote

Evernote is an online service for documents, images, web pages, and voice notes. Its greatest advantage is that your information is available via several means. The Evernote website has a sophisticated web application to view and edit your notes. There are applications available for Windows, Mac, iOS, and Android. The basic service is free and the paid service adds things like performing OCR on images and adding the words to the search index. There are also Chrome and Firefox add-ins that allow you to save a partial or entire page.

The majority of my Evernote usage is by the Windows application. The data is stored locally and synced with the website at an adjustable period. Notes are edited in a rich text editor that supports different fonts and colors, indents, bullet lists, and tables. Formatted data pasted in will retain the format of the original document.

Keeping the Log

When I started the log I kept a weekly template with horizontal rules to divide the daily entries and put a partial day/date at the top of each section. That meant every Monday morning I would have to copy this template, paste it into the end of the log, and then change seven strings like “2016.mm.dd Monday” to “2016.12.26 Monday”.

I got pretty tired of doing this and last year I started to investigate how to create a template that would suit my needs. Unfortunately paid programming work got in the way and I had to put the project aside. Also I found a 2016 calendar template on the Evernote site. I managed to edit this calendar into a usable log template. It had several drawbacks. The major one was that it was one big table so that limited how you could format things since one day was in one table cell. Also when you did an undo the document would zip back to the top, very frustrating after about April or May!

Creating a Template

This year I was determined to revive my custom template project and have a new template in place on January 1.

My original idea was to have a program create the date text and formatting data and save it into the Windows clipboard for easy pasting into Evernote. There is an Evernote XML export / import format (.enex) but I decided not to dig into that. Besides, how hard could it be to write formatted data to the clipboard? The application source is available here in Github.

The Evernote Log Application

Reading the Clipboard

First I created the function GetClipboardInfo to list the formats in the current clipboard entry and list the formats it contains.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public static StringBuilder GetClipbordInfo()
{
var sb = new StringBuilder();
var cbDataObj = Clipboard.GetDataObject();
if (cbDataObj == null)
{
return sb;
}
var fmts = cbDataObj.GetFormats();
sb.AppendLine("Data object formats: ");
foreach (var t in fmts)
{
sb.Append("\"");
sb.Append(t);
sb.AppendLine("\"");
}

After listing the formats I then check to see if an HTML Format object exists. If it exists we read it with the GetData function. The Replace function is to change the new line character to a carriage return / new line so the Winforms text control will display the line breaks.

1
2
3
4
5
6
7
8
9
10
// HTML Object
if (!cbDataObj.GetDataPresent("HTML Format"))
{
sb.AppendLine("No Html object");
}
else
{
var doc = cbDataObj.GetData("HTML Format");
sb.AppendLine(doc.ToString().Replace("\n", "\r\n"));
}

The “Version:0.9” is the beginning of the HTML Object followed by markers for the positions of the start / end of the actual HTML and the Fragment, which is what was copied. By copying parts of an Evernote note and using this tool I was able to determine what to put in the generated template.

The class GenEverLog has a single function CreateYear with a single parameter for the year to create. The HTML strings are divided between the sections before and after the date strings to be printed. The format strings are used for date formatting. These could be made variable with control settings added to the form. Also the hard coded colors in the HTML strings could likewise be made select-able.

1
2
3
4
5
6
7
8
9
10
11
private const string HtmlStart = "<span><hr/><div><span style=\"color: rgb(54, 101, 238);\"><b>";
private const string HtmlEnd = "</b></span></div><div><br/></div><div><br/></div><div><br/></div></span>";
private const string HtmlWeekStart = "<span><hr/><div><span style=\"color: rgb(123, 0, 61);\">=== <b>Week ";
private const string HtmlWeekEnd = "</b> ===</span></div><div><br/></div></span>";
private const string HtmlStartMonth = "<span><div><span><br/></span></div><hr/><div style=\"text-align: center\"><span><b><span style=\"color: rgb(50, 135, 18);\">";
private const string HtmlEndMonth = "</span></b></span></div></span>";
private const string MonthFormat = "MMM yyyy";
private const string DayFormat = "yyyy.MM.dd ddd";

From this point it is a simple matter to create a DateTime object, increment the day in a while loop, and build up a StringBuilder object with the HTML and the dates, months, and weeks. Note that a companion text only string is built up and will be sent to the clipboard. This text only string will be retrieved by applications that do not support HTML, such as Notepad.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
public static Tuple<StringBuilder, StringBuilder> CreateYear(int calendarYear)
{
var dateIncr = new DateTime(calendarYear - 1, 12, 31);
var year = calendarYear;
var lastMonth = 0;
var week = 0;
var sbHtml = new StringBuilder();
var sbText = new StringBuilder();
while (year == calendarYear)
{
// Increment date
dateIncr = dateIncr.AddDays(1);
year = dateIncr.Year;
if (year != calendarYear)
{
break;
}
var month = dateIncr.Month;
if (month != lastMonth)
{
lastMonth = month;
// Do month header
sbHtml.AppendLine($"{HtmlStartMonth}{dateIncr.ToString(MonthFormat)}{HtmlEndMonth}");
sbText.AppendLine($"{dateIncr.ToString(MonthFormat)}");
}
// Week entry
if (dateIncr.DayOfWeek.Equals(DayOfWeek.Monday))
{
sbHtml.AppendLine($"{HtmlWeekStart}{++week}{HtmlWeekEnd}");
}
// Do date entry
sbHtml.AppendLine($"{HtmlStart}{dateIncr.ToString(DayFormat)} - ({dateIncr.DayOfYear.ToString("D3")}){HtmlEnd}");
sbText.AppendLine($"{ dateIncr.ToString(DayFormat)} - ({ dateIncr.DayOfYear.ToString("D3")})");
}
sbHtml.AppendLine($"{HtmlStartMonth}End of {calendarYear}{HtmlEndMonth}");
sbText.AppendLine($"End of {calendarYear}");
ClipboardHelper.CopyToClipboard(sbHtml.ToString(), sbText.ToString());
return new Tuple<StringBuilder, StringBuilder>(sbHtml, sbText);
}

To write the HTML to a new clipboard entry, I used the ClipboardHelper code from this article by Arthur Teplitzki. I had to clean up the code copied from the web page to change Word style double quotes to regular quotes and while I was at it I changed the style to use newer C# conventions. The only functional change I made was to remove the insertion of the Doctype line.

The “Write Everlog to Clipboard Function” button will call the CreateYear function and display “Added HTML to Clipboard”. If you want to see the HTML created, simply click the “Read Clipboard” button again.

Viewing the created clipbord entry

If you are only interested in the template, the Fredwebs2017.enex file can be imported directly into Evernote. The file is included in the Github repository or download directly here.

The top of the 2017 log