glog.html 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <meta name="description" content="">
  8. <title>glog | Casey DeLorme's Portfolio / caseydelorme.com</title>
  9. <link rel="icon" type="image/x-icon" href="https://d2xxklvztqk0jd.cloudfront.net/favicon.ico" />
  10. <link rel="stylesheet" type="text/css" href="/css/main.css#c5e63ca">
  11. </head>
  12. <body>
  13. <header class="group">
  14. <h1><a href='/'>Casey DeLorme</a></h1>
  15. <nav>
  16. <ul>
  17. <li><a href="/projects">Projects</a></li>
  18. <li><a href="/resume.html">Resume</a></li>
  19. </ul>
  20. </nav>
  21. </header>
  22. <div class="content group">
  23. <h3><a href="https://github.com/cdelorme/glog">glog</a></h3>
  24. <p>I wrote this some time ago when I realized that the default <a href="https://golang.org/pkg/log/">log</a> package forced the software to exit when you called the Error functions. <em>It also does not include any context; the package, file, or line number which are immensely helpful when troubleshooting.</em></p>
  25. <p>While there are other packages that provide the functionality I would want, some mirror the default package&rsquo;s behavior, and most are relatively large or have additional dependencies.</p>
  26. <p>So I decided to write my own, which was so simple I was amazed how big some of the other packages are.</p>
  27. <p>Instead of the myriad of conflicting behaviors that a developer could embed into their application for configuration (eg. <code>-s</code> or <code>--silent</code>, <code>-q</code> or <code>--quiet</code>, literally every full or partial log level name, or a log level with severity as a value, I&rsquo;ve seen it all). <strong>Developers can ignore all that now, just let the user set <code>LOG_LEVEL</code> environment variable.</strong></p>
  28. <p>It provides standardized severities which defaults to &ldquo;Error&rdquo;. <em>I generally only use around 3~4 of them, but all of them are included.</em></p>
  29. <p>It can determine color support in the terminal and will log in color (disabled if output is redirected).</p>
  30. <p>It offers context, so you can easily debug code by tracking down the file and line number the error occurred.</p>
  31. <p>All output goes to stderr, <em>which is the optimal sane default to avoid messing with expected application output.</em></p>
  32. <p>It is concurrently safe, using a package level mutex.</p>
  33. <p>It comes with comprehensive tests, and benchmarks.</p>
  34. <p><strong>I highly recommend <a href="https://github.com/cdelorme/glog">trying it out</a>.</strong></p>
  35. <p><strong><em>written on 2017-04-13</em></strong></p>
  36. </div>
  37. <footer class="group">
  38. <a href='https://www.facebook.com/CaseyRDeLorme' class='link facebook'></a>
  39. <a href='https://www.linkedin.com/in/cdelorme' class='link linkedin'></a>
  40. <a href='https://www.youtube.com/user/LordOfElm' class='link youtube'></a>
  41. <a href='https://github.com/cdelorme' class='link github'></a>
  42. <a href='skype:casey.delorme?chat' class='link skype'></a>
  43. <div class="scripts">
  44. <script type="text/javascript" src="/js/main.js#c5e63ca" async></script>
  45. </div>
  46. </footer>
  47. </body>
  48. </html>