Kafka’s response to the outbreak of World War One was laconic. His diary entry for August 2, 1914, reads: “Germany has declared war on Russia. Went swimming in the afternoon.” As insouciance goes, it’s in a class of its own. Historians continue to argue over how accurately it conveys Kafka’s state of mind as Europe teetered on the brink – he was so neurotic it’s hard to imagine the prospect of marching armies and rolling tanks did not petrify him – but his sang froid in the face of potential meltdown is inspirational.

Not least of the miseries inflicted by the coronavirus crisis is the pervasive and escalating mood of calamity on every news channel, website and billboard. It’s no surprise it’s the only subject anyone can talk about. First thing in the morning we switch on the radio. We used to say, “turn on the news”; now we call it the bad news. Like an appointment with the dentist, it cannot be avoided. It would probably be irresponsible to tune out entirely and pretend we aren’t under siege from a potentially deadly threat, and yet there’s only so much of it I can take. Breakfast these days takes place to a soundtrack of Louis Armstrong, or Mozart, or whatever music unfailingly gladdens the heart.

I’ve never been what P G Wodehouse would call a ray of sunshine, and I’m certainly not brave. If the virus reaches me I’ll be planning my funeral – songs, venue, guest list, vegan sausage rolls – before the second sneeze. “If worst comes to worst, is there anything of mine you’d like?” a friend inquired the other day. We settled on his collection of Almodovar films. “And you?” I asked. “How about your house?”

Much has been said about the Blitz spirit of older generations, who survived war-time, and know the meaning of fear. It really is noticeable how upbeat our seventy- and eighty-something friends and neighbours are, and how reluctantly they concede that they have to be careful, if not for themselves then for others. The overriding tone of their conversation is unalarmed and sensible. An octogenarian friend in Tuscany tells me she’s about to embark on decorating her bathroom. Being cooped up is dreary, she says, “but we sing on”. It’s a beautiful phrase, suggesting not just fortitude, but grace.

Optimism seems to me as essential a commodity as antibacterial gel. Along with paracetamol and ventilators, it’s a vital weapon in this global duel. If ever there was a time to abandon innate miserabilism, our “touch wood” and “if God spares us” attitude, this is it. Cynics mock those who take a deliberately cheerful tone when things are tough, and there are few more stinging insults than to be sneered at as a “Pollyanna”. Yet Eleanor H Porter’s 1913 novel, where she introduced this lovable child, who “played the glad game”, struck a chord with many. It goes without saying that those who have tried to emulate Pollyanna’s habit of looking for the up-side in any situation usually come from circumstances where it takes real strength of character not to sink into self-pity.

True optimism is not a way of avoiding the facts – the word for that is denial. For some, being bright and positive comes naturally. They are the rubber ducks amongst us, bobbing to the surface instantly after they’ve been pushed under. For others, banishing gloom requires some policing, constantly shoring up the weak places in our mental bulwark and escorting middle-of-the-night trepidation firmly out of the door. In an emergency like this, however, it seems to me that optimism is almost obligatory. As well as not passing on germs, we should avoid spreading dread. Otherwise, we risk sliding into a morass of misery, and triggering a collective national breakdown. Is that going to happen? Don’t make me laugh.

Since one of the potential side-effects of self-isolation and apprehension is an epidemic of anxiety and depression, this needs to be tackled almost as urgently as the virus itself: feel-good radio that continues through the small hours, coronafree pages in newspapers and websites, collective singalongs from open windows, solo dancing or yoga instruction in a city square, webcammed into everyone’s home. Because, unless we actively generate cheer and deflect terror with the prospect of better things, everything we hear or see will be metaphorically edged in black.

Nobody knew better that there were two sides to the coin than Boris Johnson’s hero Winston Churchill. In private he was bedevilled by depression, but the way in which he encouraged hope, when all seemed lost, is a shining example of courage. His creed was that “a pessimist sees the difficulty in every opportunity; the optimist sees the possibility in every difficulty”. He put that principle brilliantly into practice. But had he succumbed to despair – well, it doesn’t bear thinking about.

This is certainly not the moment to indulge in morbid what-ifs. Instead it is incumbent on us to halt the spread of panic and, where possible, defuse it. The therapeutic benefit of constructing a cordon sanitaire around our thoughts will be huge. Even if it’s only for a short period every day, it will provide a mental oasis where we can relax.

Meanwhile, other positive outcomes are already noticeable, not least reduced traffic and pollution. The rise in community spirit as people – often children – make contact with neighbours they’ve never met is heart-warming. At the same time, broadcasters and other media have a responsibility to offer companionship and diversion for all those stuck at home. If they could also keep a lid on incessant and often ill-informed speculation which merely deepens despondency, that would be welcome too.

It’s only in the coming weeks, I suspect, that most of us will begin to appreciate the resilience of those who lived through world wars and other conflicts. We are facing months of disruption and peril compared with the years they endured. What’s happening right now is grim, but ultimately it might change aspects of society for the better. As we hunker down, true priorities become clear: the welfare of family, friends, neighbours and those beyond our own circle who will need help and support. Perhaps this crisis will bear out the psychoanalyst Carl Jung’s belief that “Man needs difficulties; they are necessary for health.”