ALEMIL

Welcome to a blog about application and game development

How logging can simplify complex problems

How logging can simplify complex problems 2018-07-01 20:43:56
Est. read time: 5 minutes, 32 seconds

Working with logs is a very significant part of software development. Logging means writing messages to a file (or console) describing what is happening in the application. It allows monitoring of complex systems and step by step description of its behavior.

What problems does logging solve


When you develop simple systems, you might not need to implement logging. All you need is a debugger for your language of choice and move from breakpoint to breakpoint analyzing what is going on, how values of your variables are changing.

Sometimes you will implement a bit more complex features and logging can help to simplify them. Lately, I had some issues when working with pathfinding for a 2d tile based game. From time to time the algorithm would freeze the whole game, eating too much CPU. Can you imagine pinpointing this situation with a debugger if you had about 50 AI agents that might want to go anywhere in a 192x192 grid? Well, that would be a nightmare.

Instead of debugging you could insert logging in specific points of your codebase and write proper messages describing what is going on. In the example above we might want to start by writing something like this to a text file:

[2018-07-01 12:21:05.608] [ai_path] [info] Entity 840 is moving: from 36,41 to 30,41
[2018-07-01 12:21:05.608] [ai_path] [info] Shortest path calculated in 34 ms: 6 tiles, last tile 30,41

By logging these 2 lines we can now understand where our entities want to go and how long is the path they want to take. We also identify when the last tile of the calculated path is different than what we expect.

Now when we happen to have a freeze again, we can check our log file and find which entity is breaking our game. It turned out that an entity could not get to a specific tile on the map, because there was no way available. About 36863 tiles were scanned for a potential path, but with no luck. The solution was to change the action planner to not allow picking unavailable targets and throw an exception when this situation happens again.

There is another interesting use case for logs that I stumbled upon a few months back. I had to implement an algorithm determining advertisement emission. Which ad, at which place should be displayed, given many different conditions. Even with multiple unit tests covering the codebase ensuring specific calculations return proper results, there is a risk that a whole system combining these components will not work properly.

In such case, especially when writing TDD, it's possible to test if logs are created exactly as we expect, given a specific input. It allows us to implement big features partially while testing along the way. To do this, we need to parse logs created in the test, finding if message exists.

// handler is pointing to a file holding log messages
this->checkLogExist(handler, 'Entity 4 action picked: Fishing');

The same solution can be applied when maintaining a monolithic project that doesn't work as intended and is difficult to unit test because of too many dependencies. Adding logging and some automated feature tests to old codebase can simplify it and serve as a data flow explanation.

How to write useful log messages


When writing log messages you should try to provide answers to some or all of the below questions:

  • When was the message collected? Write time and/or date depending on your needs. In production, the date might inform you if the bug happened before or after the recent patch.

  • Where was the message broadcasted? Write thread name, hostname, web application route, or class name the logger is working on.

  • What is the log level of the message? Is it a debug, info or error message? Is it critical - did your application break?

  • Why was the message produced? What conditions had to be matched for this message to be logged, what values are being held by variables that affect the state of your code?


Apart from the above, if you distribute your application to multiple machines, you might want to write the system and hardware information at the beginning of the file.

Below you can find some example logs for world creation I used in a roguelike game:
[07/01/18 20:22:03] [thread 10152] [info] Registered world locations 47, designs loaded 47
[07/01/18 20:22:03] [thread 10152] [info] Loading organizations for world maps:
[07/01/18 20:22:03] [thread 10152] [info] [1] Kabula - map 30,30,0
[07/01/18 20:22:03] [thread 10152] [info] [2] Kar Laduhr Dwarves - map 33,30,0
[07/01/18 20:22:03] [thread 10152] [info] [3] Forest folk I - map 29,29,0
[07/01/18 20:22:03] [thread 10152] [info] [4] Animals I - map 30,29,0
[07/01/18 20:22:03] [thread 10152] [info] [5] Anheluna Elves - map 29,28,0
[07/01/18 20:22:03] [thread 10152] [info] [6] Mountain Pass - map 32,30,0
[07/01/18 20:22:03] [thread 10152] [info] Starting world creation thread
[07/01/18 20:22:03] [thread 9980] [info] Starting design 30, 30, 0
[07/01/18 20:22:03] [thread 9980] [info] Adding map Kabula to world
[07/01/18 20:22:04] [thread 9980] [info] Player entity spawned at 30, 28
[07/01/18 20:22:04] [thread 9980] [info] Created 839 entities on local map
[07/01/18 20:22:04] [thread 9980] [info] Spawning organization id 1
[07/01/18 20:22:04] [thread 9980] [info] Entity [840] Human woodcutter spawned at position 35, 58
[07/01/18 20:22:04] [thread 9980] [info] Entity [843] Human woodcutter spawned at position 4, 37
[07/01/18 20:22:04] [thread 9980] [info] Entity [846] Human woodcutter spawned at position 56, 57
[07/01/18 20:22:04] [thread 9980] [info] Entity [849] Human woodcutter spawned at position 33, 40
[07/01/18 20:22:04] [thread 9980] [info] Entity [852] Human woodcutter spawned at position 36, 24
[07/01/18 20:22:04] [thread 9980] [info] Entity [855] Human fisherman spawned at position 55, 49
[07/01/18 20:22:04] [thread 9980] [info] Entity [858] Human fisherman spawned at position 21, 3
[07/01/18 20:22:04] [thread 9980] [info] Entity [862] Human fisherman spawned at position 24, 52
[07/01/18 20:22:04] [thread 9980] [info] Entity [866] Human blacksmith spawned at position 27, 11
[07/01/18 20:22:04] [thread 9980] [info] Entity [868] Magnus the Magnificent spawned at position 49, 19
[07/01/18 20:22:04] [thread 9980] [info] Local map created and saved
[07/01/18 20:22:04] [thread 9980] [info] Starting design 31, 30, 0
[07/01/18 20:22:04] [thread 9980] [info] Adding map Mountain Pass to world
[07/01/18 20:22:04] [thread 9980] [info] Created 594 entities on local map
[07/01/18 20:22:04] [thread 9980] [info] Local map created and saved
[07/01/18 20:22:04] [thread 9980] [info] Starting design 32, 30, 0
[07/01/18 20:22:04] [thread 9980] [info] Adding map Yelling cavern to world
[07/01/18 20:22:04] [thread 9980] [info] Created 3300 entities on local map
[07/01/18 20:22:04] [thread 9980] [info] Spawning organization id 6
[07/01/18 20:22:04] [thread 9980] [info] Entity [4941] Troglodyte spawned at position 45, 30
[07/01/18 20:22:04] [thread 9980] [info] Entity [4943] Troglodyte spawned at position 14, 32
[07/01/18 20:22:04] [thread 9980] [info] Entity [4945] Troglodyte spawned at position 27, 38
[07/01/18 20:22:04] [thread 9980] [info] Entity [4947] Troglodyte spawned at position 26, 50
[07/01/18 20:22:04] [thread 9980] [info] Local map created and saved
[07/01/18 20:22:04] [thread 9980] [info] Starting design 32, 30, -1
[07/01/18 20:22:04] [thread 9980] [warning] Skipping map design 32, 30, -1: no name
[07/01/18 20:22:07] [thread 9980] [info] Finished world creation, loaded player map
[07/01/18 20:22:07] [thread 10152] [info] Closing world creation thread

Conclusion


Logging messages can help you with debugging complex systems, describing how they work, applying monitoring, or even help with automated testing. When implemented correctly, you can follow the flow of your application step by step, like a diary.

On the last note, you don't have to implement logging on your own. Most languages will have libraries that can speed up the process. For C++ I can recommend spdlog, for PHP Monolog and for Java - logback. These libraries have already multiple potential issues solved for you, like thread-safety, logging to multiple files, splitting files by dates, writing different variable types and many more. If you are ever in doubt of what is happening in your application - log it.



Comments +

MAkCorps API
Breakpoints is a best alternative of logging.
2018-07-01 21:21:07
Reply
Kennetherype
Cleaning up cottages or homes is a incredibly popular service among owners of country houses. Preserving their sanitation is often quite problematic as well as tough, since it is a big location of the premises and the bordering location, there are lots of restrooms and also rooms for different purposes. Self-care for a lodge can be fairly hard, given that the procedure requires the accessibility of extremely various house chemicals, devices as well as takes a lot of time.

RAPIDLY As Well As SUCCESSFULLY
We make every effort not to waste time, but at the same time do not hurry to the detriment of the result. Our group includes professionals of the highest degree in all locations.

TRUTHFUL PRICES WITHOUT HIDDEN SUPPLEMENTS

Our rates are dealt with and also depend just on the area. We guarantee the safety of the rate approximately a dime.

TIME PLAYS ROLE

We value the time and also know a lot about the advantages. We agree on the phone and come promptly to clean.

Business currently have all the essential cleansing equipment, cleaning products of European top quality and experienced staff that can quickly cope with even the most difficult spots. Prior to becoming part of a agreement, the supervisor as well as the customer identify the entire package of services, whether it is simply general or comprehensive cleansing, whether additional home window cleansing or upholstered furniture is needed. Leave a demand, and also our manager will address questions, trigger you on a set of services and compute the expense of cleaning free of cost. We welcome you to comply.

In residence cleaning company - best
Maid service nj
- it is actually easy, hassle-free as well as cost effective with our business.
Depend on the sanitation innovators to home cleansing Brooklyn! We utilize expert laundry detergents and technical equipment of global suppliers in our work and also carry out an exceptional job along with cleaning of any sort of intricacy.

8]Professional house cleaning rates nyc

Collaboration along with the business is the sponsor of an impeccable, rewarding and also dependable cleaning of specialist home cleansing and also neighboring places. Presently, property cleaning services coming from our firm are actually made use of in New Jersey. Cherish as well as you the true perks as well as functional benefits of our service plan.

Through signing a long-term company deal with our company, you will definitely manage to leave the requirement to maintain a large team of technical staff, which, in turn, will certainly enhance expenses. The price of the complicated, daily, basic home cleansing of Staten Island, done by our workers, will definitely always be actually less than the cost of earnings for cleaning services, the purchase of cleaning products as well as tools.

6]Housekeeping jobs hiring ny

Leave behind an ask for on the site, specify your label or even firm title, call phone number and also day of desired cleaning, leave your wishes and also needs in a message to the manager if needed, at that point our professional will contact you in the fastest time as well as specify the day, time and place of work!
2020-07-19 11:40:28
Reply
agrohimhfq
удалите,пожалуйста! .






li.d.e.r.p.r.o.m.o.20.15.su.p.er@gmail.com
l.ide.r.pro.m.o.2015.su.per@gmail.com
l.ide.rpromo.20.1.5.s.u.p.e.r@gmail.com
li.de.r.pro.m.o.2015s.up.er@gmail.com
li.der.p.r.omo.2.015.supe.r@gmail.com
2020-07-22 01:15:55
Reply
AinyOmink
Which photo do you like best? I have many more photos (photos are clickable)*

2020-07-29 21:09:35
Reply
Errodiaodolo
mature amateur big black cock blowjobs

naked amateur girlfriend blowjob

real amateur gay blowjob

true amateur home video of teens giving blowjob

tumblr amateur black blowjob

webcam teen amateurs blowjob

retro amateur blowjob pic

sensual amateur blowjob and swallow

blowjob in the dark amateur

blowjob gif amateur pov

.
.
.

Wife Bucket is a premium amateur site starring gorgeous married women pleasing their husbands, lovers, strangers, and more – there’s just so much here. If you want 33 sites chock full of fantastic themed eastern European or specifically Czech hardcore reality porn, there’s really only one option: Czech AV.
Check out best Devil Girl HD porn videos on xHamster. Watch all best Devil Girl HD XXX vids right now!
Schoolgirl Pics. Schoolgirl Solo. Asian Schoolgirl. Schoolgirl Anal. Schoolgirl Threesome. Naughty Bookworms. Japanese Schoolgirl.
2020-08-01 07:34:09
Reply
RoxanaNex


Phim Hay DЖ°ЖЎng Mб»‹ch 2020CA Nб»® BГЃO THГ™ - Tбє¬P CUб»ђI (Lб»“ng Tiбєїng)
2020-08-03 08:44:42
Reply
WiSkype
Restoration of baths
2020-08-07 20:26:18
Reply
teworksed
cvvshopsonline
2020-08-09 03:03:54
Reply
FraACrog
Restoration of baths in Orekhovo-Zuyevo
2020-07-19 13:15:09
Reply
Adrianojah
Regards, Good information! loans online instant approval
2020-07-25 07:46:14
Reply
Errodiaodolo
60's amateur group porn videos free

amateur mom likes to watch porn videos

amateur mrs cuckolding so films porn

amateur porn married eating out wife

amateur wife flash work porn vids

amateur only submmlitted hidden cam porn

amateur gay cars cruising group play porn

amateur black teen doing white old guy porn

amateur takes bbc deep porn videos

amateur bi husband glory hole porn

.
.
.

Milf Hippie girl getting fucked, blowjob, and cumshot. Girls out west teen Hatefuck my hippie asshole. Amateur Hippie Girl Has Some HUGE Titties. Hippy girl getting the D outdoor. Hippy partner banged about the sofa. Fucking fuck that is hippies and anal.
Watch Amateur Hippy Couple Anal in the Woods video on xHamster, the biggest sex tube site with tons of free Mobile Couple New Tube & Twitter porn movies!
Relish our big archive of Hippy Videos Porno XXX at SSS.xxx tube! All mobile xxx videos will make you horny very quickly!
2020-07-30 11:39:50
Reply
UntormSmoons
The cleaning firm accomplishes cleansing of areas of different sizes and arrangements.

We offer expert the maid service for personal customers. Utilizing European equipment and accredited tools, we attain optimal outcomes and also give cleaning quickly.

The firm's experts provide cleaning with the aid of modern innovations, have unique tools, and additionally have accredited cleaning agents in their arsenal. In addition to the above advantages, wines provide: favorable prices; cleaning quickly; premium quality outcomes; greater than 100 positive testimonials. Cleansing workplaces will help keep your office in order for the most effective job. Any business is exceptionally crucial atmosphere in the group. Cleaning solutions that can be gotten cheaply now can assist to arrange it as well as offer a comfortable area for labor.

If necessary, we leave cleaning the cooking area 2-3 hrs after putting the order. You get cleansing asap.

We offer discount rates for those that make use of the solution for the first time, as well as favorable terms of teamwork for normal customers.

We supply premium cleaning for large enterprises as well as tiny companies of different instructions, with a discount of approximately 25%.

Our pleasant group uses you to obtain acquainted with positive regards to participation for company customers. We sensibly approach our activities, tidy making use of expert cleaning products and also specialized equipment. Our employees are educated, have medical publications and are familiar with the nuances of removing complex as well as hard-to-remove dust from surface areas.
2020-08-02 02:50:43
Reply
Errodiaodolo
marthabullles
amateur girls do porn gallery

amateur rape teen porn

amateur scream moms porn

amateur asians screaming bbc porn

amateur very young boy porn

amateur blonde double penetration porn

amateur porn picture torrent dowland

.
.
.

Slutty wife masturbates while her husband fucks his ex. Shameless mature wife cheating on husband with her ex husband in hotel room. Husband films his busty wife enjoying hot sex with her ex. Naughty and sexy teen gets hard fucked by her ex in front of his wife. Busty mature wife likes her pussy to be eates out by her ex husband.
Watch Black Friend Fucks Wife very Deep and Unloads video on xHamster - the ultimate archive of free Free Black No Sign up & Mature porn tube movies! ... This is exactly how a cuck pictures, wants and expects his wife to be fucked by her Bull. 1 year ago. Reply. C. cuckslut.
Watch Nasty Whore Goes Ass to Mouth in Bar Bathroom video on xHamster - the ultimate selection of free Anal & Xxx hardcore porn tube movies! ... Slutty & Submissive Amateur Gets Used Like A Fuck Toy . 451,016. 96%. 12:53. Must See Amateur Vid. 876,195. 99%. ... Your wife or girlfriend would guess anything :-P My girly holes are for you guys to ...
2020-08-04 16:52:06
Reply
Errodiaodolo
marthabullles
amateur bisexual orgy guys swapping cum

amateur tiny dick street meat cumming

best amateur cum selfie gif

best amateur head with cum compilation

cum sucking mature amateurs in stockings

amateur employee swallows my cum

amateur black cd cum fuck

amateur husband eats his own cum

amateur begs him to cum

gay amateur sex compilation cum tubes

.
.
.

Voyeur of amateur asian body massage 3 weeks ago 1:12:58 IcePorn massage, redhead, amateur, asian, voyeur; Applying Gently Pressure To Her Vagina Is Good 3 months ago 13:27 xHamster arab, massage; Genevieve LaFleur - Massive Massage 1 week ago 40:25 YouPorn teen (18+), anal, big cock, mature anal, big ass; Inked massage babe with bigtits torn up
Watch A1 Amateur Asian pussy lips gripping BBC in doggy on SpankBang now! - Homemade, Asian Amateur, Amateur, Asian, Big Dick, Cam, Ebony, Hardcore, Interracial, Japanese, Pov Porn - SpankBang
PASSION-HD Asian Teen Spreads Pussy Wide For Big Dick. nsfw. nsfw. pornsource.xyz/asian-... 1. 0 comments. share. save hide report. 1. Posted by 5 days ago. Perfect Amateur Asian Teen Pussy View more Asianteenpussy.xyz ... Asian Hot 24. nsfw. nsfw. pornsource.xyz/asian-... 1. 0 comments. share. save hide report. 0. Posted by 1 day ago. white ...
2020-08-08 06:56:18
Reply
Errodiaodolo
marthabullles
lesbian amateur sex selfie

lesbian amateur wives sex tape

lesbian pussy pounding amateur

free mobile porn amateur lesbian

young teen amateur lesbians

real lesbian spycam amateurs

sexy teen amateur lesbian sex

skinny amateur shaved teen lesbians

milf lesbian rimjob amateur

nude amateur college lesbians

.
.
.

Free Mom XXX Videos: Mom, Japanese, Son, Anal, Stepmom, Indian amateur, Mature, Milf, Dad, Indian, Granny, Mother, Monster cock, Monster, Midget, Sister, Tied up, Lesbian, Yoga, Mommy, Mom porn. ... A accident 1 adorable 21 adultery 6 african 4 aged 48 allure 6 amateur 5514 american 143 anal 2282 anal-creampie 151 anal-finger 101 anal-first ...
Curly Hair Mom Free milf porn videos by the thousands and tons of options to improve you naughty porn experience, only at this smashing hot mom porn tube, the best place where you can delight yourself with beauties in their middle ages, cracking huge dicks into their warm pussies or warm asses during truly rare and exclusively selected porn videos.
Michigan youth basketball events, tournaments, leagues, camps/clinics and tryouts posted by event directors, amatuer organizations and youth teams.
2020-08-09 21:51:44
Reply
rardzer
Hello. And Bye.
2019-07-01 11:05:49
Reply
Inga
фотографии кубанские
2020-07-21 14:36:47
Reply
Geraldslini
Odintsovo restoration of the bath cover
2020-07-28 07:11:51
Reply
Errodiaodolo
cock sleeve amateur porno

teen amateur first black cock

tiny amateur takes big cock

monster cock forced deepthroat amateur

panties amateur suck cock

monster cock asian amateur dp

old cock suckers amateurs

real amateur mom huge cock

sexy amateur wants his cock

giant cock amateurs sex

.
.
.

Teen Missionary XXX Videos. Fuck buddy gets to pound that teen pussy hard and fast. Cute looking teen girl worships that big dick so much. Great natural girl has the body of a nubile temptress. Some dark sex with 18 year old girls that are horny for threesome. Young beautiful sexy teen photo model gets drilled immensely hard.
Horny amateur mom get fucked 85.77% 15 7. 1 Tags: amateur mom amateur mom porn mom real homemade porn mamma amatoriale horny mom real amateur porn taboo hmong homemade mom mom amateur amazonian porn mom real mom homemade real homemade real mom horny amateur mom stockings playa. Comments (1): Post a comment. Copy page link.
Watch Amateur Mom gets Fucked video on xHamster, the best sex tube site with tons of free Amateur Moms MILF & Free Mom Tube porn movies!
2020-07-30 23:41:46
Reply
rardzer
hello everyone thanks for approve
2019-10-12 08:39:53
Reply
Errodiaodolo
marthabullles
amateur creampie bbc compilation

amateur creampie compilation subtitles

amateur creampie gangbang tube

amateur creampie mature comp

amateur creampie sex -search

amateur creampie threesome ff.

amateur creampie video reddit

amateur creampied pussy and ass

amateur creampies collection torrent

amateur creampies scarlett red

.
.
.

Sexy Blond Feeds Ginger Cum In Parking Lot; Slutty Girl Gets Mouth Full Of Cum In Public Park; White Wife Sucking Bbc In The Club Parking Lot; Mouthful Of Cum For Wife Next To Car In Park! Teacher Sucking Bbc In School Parking Lot; Cheating Milf Sucks Off A Stranger In The Parking Lot; Two Couples Have Sex In The Parking Lot; Dude Sucking ...
Straight guy eats boy cum off of booty videos and homosexual porn straight. Tags: booty ... Boy ass fucking big booty gay sex doll So let it be known that Castro. Tags ... Tags: booty, french. 48 days ago. 0:05. xHamster. Big booty pt2. Tags: amateur, black, booty, hd, masturbation. 14 days ago. 6:10. GayBingo. Dilf dude booty-fucked while ...
Prime Cups Natural Big Tits Get Titty Fucked And Cum On. ... Cute Big Tits Teen. Big Tit Teen Gets Fucked By A Huge Cock. All Natural Big Tits Feature. ... Anal Amateur Anal Beads Anal Creampie Anal Fisting Anal Mature Anal Teen Anal Toying Animation Anime Arab Argentinian Asian Ass Ass ...
2020-08-02 10:19:32
Reply
UntormSmoons
The cleansing business carries out cleansing of areas of numerous dimensions and also setups.

We supply specialist maid for you cleaning service for personal customers. Making use of European equipment as well as certified devices, we accomplish maximum results and also give cleansing quickly.

The business's professionals give cleansing with the help of contemporary innovations, have unique tools, and additionally have certified detergents in their arsenal. Along with the above advantages, red wines supply: desirable prices; cleaning in a short time; high quality results; greater than 100 favorable evaluations. Cleaning up offices will assist maintain your work environment in order for the most productive job. Any type of company is incredibly important ambience in the group. Cleaning up solutions that can be purchased inexpensively now can aid to prepare it and also offer a comfy room for labor.

If necessary, we leave cleaning the kitchen area 2-3 hrs after placing the order. You get cleaning immediately.

We offer discounts for those that make use of the service for the very first time, along with positive regards to cooperation for regular clients.

We supply premium cleansing for huge business and also little companies of different instructions, with a discount of up to 25%.

Our pleasant team uses you to get familiarized with beneficial terms of collaboration for company clients. We responsibly approach our tasks, tidy using professional cleansing items as well as customized tools. Our workers are educated, have clinical publications as well as know with the nuances of getting rid of facility and hard-to-remove dirt from surfaces.
2020-08-07 18:31:01
Reply
Lesliefreet


Hermitcraft 7: Episode 35 - THE NETHERITE KING
2020-08-08 07:35:07
Reply
profpAlose
http://profiplast.org
2020-08-10 19:48:22
Reply