Commit 2e8a3d5b2f1c6c24b48a3e25db4b89f49b76703d

Stephen Moloney 2016-02-18T09:27:48

replace LoggingUtils dependency with Og.

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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
diff --git a/lib/hubic/hubic_api/auth.ex b/lib/hubic/hubic_api/auth.ex
index 0fc028d..9ca8886 100644
--- a/lib/hubic/hubic_api/auth.ex
+++ b/lib/hubic/hubic_api/auth.ex
@@ -45,7 +45,7 @@ defmodule ExOvh.Hubic.HubicApi.Auth do
   """
   @spec get_latest_access_token(refresh_token :: String.t, config :: map) :: map
   def get_latest_access_token(refresh_token, config) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     auth_credentials = config.client_id <> ":" <> config.client_secret
     auth_credentials_base64 = Base.encode64(auth_credentials)
     req_body = "refresh_token=" <> refresh_token <>
diff --git a/lib/hubic/hubic_api/cache.ex b/lib/hubic/hubic_api/cache.ex
index fdfa69f..e2d0ec1 100644
--- a/lib/hubic/hubic_api/cache.ex
+++ b/lib/hubic/hubic_api/cache.ex
@@ -38,7 +38,7 @@ defmodule ExOvh.Hubic.HubicApi.Cache do
 
   @doc "Starts the genserver"
   def start_link({client, config, opts}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     GenServer.start_link(__MODULE__, {client, config, opts}, [name: gen_server_name(client)])
   end
 
@@ -64,14 +64,14 @@ defmodule ExOvh.Hubic.HubicApi.Cache do
   # trap exits so that terminate callback is invoked
   # the :lock key is to allow for locking during the brief moment that the access token is being refreshed
   def init({client, config, _opts}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     :erlang.process_flag(:trap_exit, :true)
     create_ets_table(client)
     refresh_token = config.refresh_token
     case refresh_token  do
       :nil -> # RAISE AN EXCEPTION DUE TO UNAVAILABILITY OF THE REFRESH TOKEN
         error = "Valid refresh token not available"
-        LoggingUtils.log_return(error, :error)
+        Og.log_return(error, :error)
         raise error
       refresh_token -> # TRY TO GET REFRESH TOKEN FROM THE CONFIG
         tokens = get_latest_tokens(%{"refresh_token" => refresh_token}, config) |> Map.put(:lock, :false)
@@ -82,21 +82,21 @@ defmodule ExOvh.Hubic.HubicApi.Cache do
   end
 
   def handle_call(:add_lock, _from, {client, config, tokens}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     new_tokens = Map.put(tokens, :lock, :true)
     :ets.insert(ets_tablename(client), {:tokens, new_tokens})
     {:reply, :ok, new_tokens}
   end
 
   def handle_call(:remove_lock, _from, {client, config, tokens}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     new_tokens = Map.put(tokens, :lock, :false)
     :ets.insert(ets_tablename(client), {:tokens, new_tokens})
     {:reply, :ok, new_tokens}
   end
 
   def handle_call(:update_tokens, _from, {client, config, tokens}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     new_tokens = get_latest_tokens(tokens, config)
     |> Map.put(tokens, :lock, :false)
     :ets.insert(ets_tablename(client), {:tokens, new_tokens})
@@ -104,17 +104,17 @@ defmodule ExOvh.Hubic.HubicApi.Cache do
   end
 
   def handle_call(:get_config, _from, {client, config, tokens}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     {:reply, config, {client, config, tokens}}
   end
 
   def handle_call(:stop, _from, {client, config, tokens}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     {:stop, :shutdown, :ok, {client, config, tokens}}
   end
 
   def terminate(:shutdown, {client, config, tokens}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     :ets.delete(ets_tablename(client))
     :ok
   end
@@ -129,7 +129,7 @@ defmodule ExOvh.Hubic.HubicApi.Cache do
 
   # get the token from the :ets table
   defp get_token(client, index) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     if ets_tablename(client) in :ets.all() do
       [tokens: tokens] = :ets.lookup(ets_tablename(client), :tokens)
       if tokens.lock === :true do
@@ -156,7 +156,7 @@ defmodule ExOvh.Hubic.HubicApi.Cache do
   # Returns a map in following format with the latest tokens:
   # %{"access_token" => "access_token", "expires_in" => 21600, "refresh_token" => "refresh_token", "token_type" => "Bearer"}
   defp get_latest_tokens(tokens, config) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     Auth.get_latest_access_token(tokens["refresh_token"], config)
     |> Map.put("refresh_token", tokens["refresh_token"])
   end
@@ -166,7 +166,7 @@ defmodule ExOvh.Hubic.HubicApi.Cache do
   # expires_in parameter is in seconds
   # This function is used as a worker `Task` everytime the genserver is initialised.
   defp monitor_expiry(client, expires_in) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     interval = (expires_in - 30) * 1000
     :timer.sleep(interval)
     {:reply, :ok, _state} = GenServer.call(gen_server_name(client), :add_lock)
@@ -177,7 +177,7 @@ defmodule ExOvh.Hubic.HubicApi.Cache do
 
   # creates the ets table
   defp create_ets_table(client) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     ets_options = [
                    :set, # type
                    :protected, # read - all, write this process only.
diff --git a/lib/hubic/hubic_api/request.ex b/lib/hubic/hubic_api/request.ex
index fba7ac6..e3d4853 100644
--- a/lib/hubic/hubic_api/request.ex
+++ b/lib/hubic/hubic_api/request.ex
@@ -9,9 +9,9 @@ defmodule ExOvh.Hubic.HubicApi.Request do
 
   def request(client, {method, uri, params} = query, opts, retries \\ 0) do
     {method, uri, options} = Auth.prepare_request(client, query)
-    LoggingUtils.log_return({method, uri, options}, :debug)
+    Og.log_return({method, uri, options}, :debug)
     resp = HTTPotion.request(method, uri, options)
-    |> LoggingUtils.log_return(:debug)
+    |> Og.log_return(:debug)
     if resp.status_code >= 100 and resp.status_code < 300 do
       try do
         {:ok, %{
diff --git a/lib/hubic/openstack_api/cache.ex b/lib/hubic/openstack_api/cache.ex
index 94b7344..aac5e68 100644
--- a/lib/hubic/openstack_api/cache.ex
+++ b/lib/hubic/openstack_api/cache.ex
@@ -15,7 +15,7 @@ defmodule ExOvh.Hubic.OpenstackApi.Cache do
 
   @doc "Starts the genserver"
   def start_link({client, config, opts}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     GenServer.start_link(__MODULE__, {client, config, opts}, [name: gen_server_name(client)])
   end
 
@@ -57,13 +57,13 @@ defmodule ExOvh.Hubic.OpenstackApi.Cache do
   # trap exits so that terminate callback is invoked
   # the :lock key is to allow for locking during the brief moment that the access token is being refreshed
   def init({client, config, opts}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     :erlang.process_flag(:trap_exit, :true)
     token = Cache.get_token(client)
     :timer.sleep(@init_delay) # give some time for TokenCache Genserver to initialize
     create_ets_table(client)
     {:ok, resp} = Request.request(client, {:get, "/account/credentials", :nil}, %{})
-    |> LoggingUtils.log_return(:debug)
+    |> Og.log_return(:debug)
     credentials = Map.put(resp.body, :lock, :false)
     :ets.insert(ets_tablename(client), {:credentials, credentials})
     expires = to_seconds(credentials["expires"])
@@ -73,19 +73,19 @@ defmodule ExOvh.Hubic.OpenstackApi.Cache do
 
 
   def handle_call(:add_lock, _from, {client, config, credentials}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     new_credentials = Map.put(credentials, :lock, :true)
     :ets.insert(ets_tablename(client), {:credentials, new_credentials})
     {:reply, :ok, {client, config, new_credentials}}
   end
   def handle_call(:remove_lock, _from, {client, config, credentials}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     new_credentials = Map.put(credentials, :lock, :false)
     :ets.insert(ets_tablename(client), {:credentials, new_credentials})
     {:reply, :ok, {client, config, new_credentials}}
   end
   def handle_call(:update_credentials, _from, {client, config, credentials}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     {:ok, resp} = Request.request(client, {:get, "/account/credentials", ""}, %{})
     new_credentials = resp.body
     |> Map.put(credentials, :lock, :false)
@@ -93,11 +93,11 @@ defmodule ExOvh.Hubic.OpenstackApi.Cache do
     {:reply, :ok, {client, config, new_credentials}}
   end
   def handle_call(:stop, _from, state) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     {:stop, :shutdown, :ok, state}
   end
   def terminate(:shutdown, {client, config, credentials}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     :ets.delete(ets_tablename(client)) # explicilty remove
     :ok
   end
@@ -113,7 +113,7 @@ defmodule ExOvh.Hubic.OpenstackApi.Cache do
 
 
   defp get_credentials(client, index) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     if ets_tablename(client) in :ets.all() do
       [credentials: credentials] = :ets.lookup(ets_tablename(client), :credentials)
       if credentials.lock === :true do
@@ -138,7 +138,7 @@ defmodule ExOvh.Hubic.OpenstackApi.Cache do
 
 
   defp monitor_expiry(client, expires) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     interval = (expires - 30) * 1000
     :timer.sleep(interval)
     {:reply, :ok, _credentials} = GenServer.call(gen_server_name(client), :add_lock)
@@ -150,7 +150,7 @@ defmodule ExOvh.Hubic.OpenstackApi.Cache do
 
 
   defp create_ets_table(client) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     ets_options = [
                    :set, # type
                    :protected, # read - all, write this process only.
diff --git a/lib/hubic/openstack_api/request.ex b/lib/hubic/openstack_api/request.ex
index 21af5f4..a4e9793 100644
--- a/lib/hubic/openstack_api/request.ex
+++ b/lib/hubic/openstack_api/request.ex
@@ -7,11 +7,11 @@ defmodule ExOvh.Hubic.OpenstackApi.Request do
   @spec request(client :: atom, query :: ExOvh.Client.raw_query_t, opts :: map)
                 :: {:ok, ExOvh.Client.response_t} | {:error, ExOvh.Client.response_t}
   def request(client, {method, uri, params} = query, opts) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     {method, uri, options} = Auth.prepare_request(client, query)
-    |> LoggingUtils.log_return(:debug)
+    |> Og.log_return(:debug)
     resp = HTTPotion.request(method, uri, options)
-    |> LoggingUtils.log_return(:debug)
+    |> Og.log_return(:debug)
 
     if resp.status_code >= 100 and resp.status_code < 300 do
       try do
diff --git a/lib/hubic/request_helpers.ex b/lib/hubic/request_helpers.ex
index 18c4afc..2ca74a8 100644
--- a/lib/hubic/request_helpers.ex
+++ b/lib/hubic/request_helpers.ex
@@ -25,7 +25,7 @@ defmodule ExOvh.Hubic.RequestHelpers do
     account = OpenCache.get_account(client)
     case ExOvh.hubic_request(account_info(account), %{ openstack: :true }) do
       {:ok, resp} ->
-        LoggingUtils.log_return(resp)
+        Og.log_return(resp)
         {:ok, resp.body |> Enum.map(fn(%{"name" => container}) -> container end)}
       {:error, resp} ->
         {:error, resp}
@@ -64,7 +64,7 @@ defmodule ExOvh.Hubic.RequestHelpers do
     account = OpenCache.get_account(client)
     case ExOvh.hubic_request(get_objects(account, container), %{ openstack: :true }) do
       {:ok, resp} ->
-        LoggingUtils.log_return(resp)
+        Og.log_return(resp)
         {:ok, resp.body |> Enum.map(fn(%{"name" => object_name}) -> object_name end)}
       {:error, resp} ->
         {:error, resp}
@@ -75,7 +75,7 @@ defmodule ExOvh.Hubic.RequestHelpers do
     account = OpenCache.get_account(client)
     case ExOvh.hubic_request(get_objects(account, container), %{ openstack: :true }) do
       {:ok, resp} ->
-        LoggingUtils.log_return(resp)
+        Og.log_return(resp)
         {:ok, resp.body |> Enum.map(fn(%{"hash" => object_hash}) -> object_hash end)}
       {:error, resp} ->
         {:error, resp}
diff --git a/lib/hubic/supervisor.ex b/lib/hubic/supervisor.ex
index 5b22a21..76b7602 100644
--- a/lib/hubic/supervisor.ex
+++ b/lib/hubic/supervisor.ex
@@ -1,7 +1,6 @@
 defmodule ExOvh.Hubic.Supervisor do
   @moduledoc :false
   use Supervisor
-  alias LoggingUtils
   alias ExOvh.Hubic.HubicApi.Cache, as: TokenCache
   alias ExOvh.Hubic.OpenstackApi.Cache, as: OpenstackCache
 
@@ -10,7 +9,7 @@ defmodule ExOvh.Hubic.Supervisor do
   #####################
 
   def start_link(client, config, opts) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     Supervisor.start_link(__MODULE__, {client, config, opts}, [name: supervisor_name(client)])
   end
 
@@ -19,7 +18,7 @@ defmodule ExOvh.Hubic.Supervisor do
   #####################
 
   def init({client, config, opts}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     workers = [
                 {TokenCache, {TokenCache, :start_link, [{client, config, opts}]}, :permanent, 15000, :worker, [TokenCache]},
                 {OpenstackCache, {OpenstackCache, :start_link, [{client, config, opts}]}, :permanent, 20000, :worker, [OpenstackCache]}
diff --git a/lib/mix/tasks/hubic.ex b/lib/mix/tasks/hubic.ex
index a6df87e..79a5793 100644
--- a/lib/mix/tasks/hubic.ex
+++ b/lib/mix/tasks/hubic.ex
@@ -60,9 +60,9 @@ defmodule Mix.Tasks.Hubic do
 
 
   def run(args) do
-    LoggingUtils.log_return(args, :debug)
+    Og.log_return(args, :debug)
     opts_map = parse_args(args)
-    LoggingUtils.log_return(opts_map, :debug)
+    Og.log_return(opts_map, :debug)
     IO.inspect(opts_map, pretty: :true)
     Mix.Shell.IO.info("")
     Mix.Shell.IO.info("The details in the map above will be used to get the hubic refresh token.")
@@ -91,7 +91,7 @@ defmodule Mix.Tasks.Hubic do
 
   defp parse_args(args) do
     {opts, _, _} = OptionParser.parse(args)
-    LoggingUtils.log_return(opts, :debug)
+    Og.log_return(opts, :debug)
     {opts, opts_map} = opts
     |> has_required_args()
     |> parsers_login()
@@ -140,7 +140,7 @@ defmodule Mix.Tasks.Hubic do
   # - Sends the application/x-www-form-urlencoded information to the @hubic_auth_uri on behalf of the user
   # - Parses and returns the authorisation code inside the opts_map
   defp get_auth_code(opts_map) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     query_string = "?client_id=" <> opts_map.client_id <>
                    "&redirect_uri=" <> URI.encode_www_form(opts_map.redirect_uri) <>
                    "&scope=" <> "usage.r,account.r,getAllLinks.r,credentials.r,sponsorCode.r,activate.w,sponsored.r,links.drw" <>
@@ -205,7 +205,7 @@ defmodule Mix.Tasks.Hubic do
 
 
   defp get_validated_inputs(resp_body) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     inputs = Floki.find(resp_body, "form input[type=text], form input[type=password], form input[type=checkbox], form input[type=hidden]")
     |> List.flatten()
     if Enum.any?(inputs, fn(input) -> input === [] end), do: raise "Empty input found"
@@ -215,7 +215,7 @@ defmodule Mix.Tasks.Hubic do
   #- Adds the refresh_token to the opts_map
   @spec get_refresh_token(opts_map :: map) :: map
   defp get_refresh_token(opts_map) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     auth_credentials = opts_map.client_id <> ":" <> opts_map.client_secret
     auth_credentials_base64 = Base.encode64(auth_credentials)
     req_body = "code=" <> opts_map.auth_code <>
diff --git a/lib/mix/tasks/ovh.ex b/lib/mix/tasks/ovh.ex
index 101fb1f..5d212ba 100644
--- a/lib/mix/tasks/ovh.ex
+++ b/lib/mix/tasks/ovh.ex
@@ -164,7 +164,7 @@ defmodule Mix.Tasks.Ovh do
 
   defp parse_args(args) do
     {opts, _, _} = OptionParser.parse(args)
-    LoggingUtils.log_return(opts, :debug)
+    Og.log_return(opts, :debug)
     {opts, opts_map } = opts
     |> has_required_args()
     |> parsers_login()
@@ -262,7 +262,7 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp get_app_create_page(opts_map) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     options = [ timeout: @timeout ]
     default_create_app_uri(opts_map)
     %HTTPotion.Response{body: resp_body, headers: headers, status_code: status_code} =
@@ -272,7 +272,7 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp get_create_app_inputs(resp_body) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     inputs = Floki.find(resp_body, "form input")
     |> List.flatten()
     if Enum.any?(inputs, fn(input) -> input === [] end), do: raise "Empty input found"
@@ -281,7 +281,7 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp build_app_request(inputs, %{login: login, password: password} = opts_map) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     {acc, _index, _max} =
     Enum.reduce(inputs, {"", 1, Enum.count(inputs)}, fn({"input", input, _}, acc) ->
       name = :proplists.get_value("name", input)
@@ -312,7 +312,7 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp send_app_request(req_body, opts_map) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     uri = Defaults.endpoints()[opts_map.endpoint] <> "createApp/"
     resp = HTTPotion.request(:post, uri, [body: req_body, headers: ["Content-Type": "application/x-www-form-urlencoded"]])
     error_msg1 = "There is already an application with that name for that Account ID"
@@ -351,14 +351,14 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp get_consumer_key(%{access_rules: access_rules, redirect_uri: redirect_uri} = opts_map) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     body = %{ accessRules: access_rules, redirection: redirect_uri }
     # {method, uri, options} = Auth.ovh_prepare_request(ExOvh, query, %{})
     options = %{ body: Poison.encode!(body), headers: Map.merge(@default_headers, %{ "X-Ovh-Application": app_key(opts_map) } ), timeout: @timeout }
-    |> LoggingUtils.log_return(:debug)
+    |> Og.log_return(:debug)
 
-    LoggingUtils.log_return(consumer_key_uri(opts_map), :debug)
-    LoggingUtils.log_return(options, :debug)
+    Og.log_return(consumer_key_uri(opts_map), :debug)
+    Og.log_return(options, :debug)
 
     body = HTTPotion.request(:post, consumer_key_uri(opts_map), options) |> Map.get(:body) |> Poison.decode!()
     {Map.get(body, "consumerKey"), Map.get(body, "validationUrl")}
@@ -386,7 +386,7 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp build_ck_binding_request(inputs, %{login: login, password: password} = opts_map) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     {acc, _index, _max} =
     Enum.reduce(inputs, {"", 1, Enum.count(inputs)}, fn({type, input, options}, acc) ->
       {name_val, value} =
@@ -424,7 +424,7 @@ defmodule Mix.Tasks.Ovh do
 
 
   defp send_ck_binding_request(req_body, validation_url, ck) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     resp = HTTPotion.request(:post, validation_url, [body: req_body, headers: ["Content-Type": "application/x-www-form-urlencoded"]])
     error_msg1 = "Failed to bind the consumer token to the application. Please try to validate the consumer token manually at #{validation_url}"
     error_msg2 = "Invalid validity period entered for the consumer token. Please try to validate the consumer token manually at #{validation_url}"
diff --git a/lib/ovh/openstack_api/webstorage/auth.ex b/lib/ovh/openstack_api/webstorage/auth.ex
index b70a3ff..6e432ef 100644
--- a/lib/ovh/openstack_api/webstorage/auth.ex
+++ b/lib/ovh/openstack_api/webstorage/auth.ex
@@ -20,7 +20,7 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Auth do
     if params !== :nil and params !== "", do: uri = uri <> "?" <> URI.encode_query(params)
     options = %{ headers: headers(client, service), timeout: @timeout }
     {method, uri, options}
-    |> LoggingUtils.log_return(:debug)
+    |> Og.log_return(:debug)
   end
 
   def prepare_request(client, {method, uri, params} = query, service) when method in [:post, :put] do
@@ -28,7 +28,7 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Auth do
     if params !== "" and params !== :nil and is_map(params), do: params = Poison.encode!(params)
     options = %{ body: params, headers: headers(client, service), timeout: @timeout }
     {method, uri, options}
-    |> LoggingUtils.log_return(:debug)
+    |> Og.log_return(:debug)
   end
 
 
diff --git a/lib/ovh/openstack_api/webstorage/cache.ex b/lib/ovh/openstack_api/webstorage/cache.ex
index eeea32f..1f2bc58 100644
--- a/lib/ovh/openstack_api/webstorage/cache.ex
+++ b/lib/ovh/openstack_api/webstorage/cache.ex
@@ -14,7 +14,7 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Cache do
 
   @doc "Starts the genserver"
   def start_link({client, config, opts}, service) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     GenServer.start_link(__MODULE__, {client, service}, [name: gen_server_name(client, service)])
   end
 
@@ -57,7 +57,7 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Cache do
   # trap exits so that terminate callback is invoked
   # the :lock key is to allow for locking during the brief moment that the access token is being refreshed
   def init({client, service}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     :erlang.process_flag(:trap_exit, :true)
     create_ets_table(client, service)
     {:ok, credentials} = identity(service)
@@ -69,21 +69,21 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Cache do
   end
 
   def handle_call(:add_lock, _from, {client, service, credentials}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     new_credentials = Map.put(credentials, :lock, :true)
     :ets.insert(ets_tablename(client, service), {:credentials, new_credentials})
     {:reply, :ok, {client, service, new_credentials}}
   end
 
   def handle_call(:remove_lock, _from, {client, service, credentials}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     new_credentials = Map.put(credentials, :lock, :false)
     :ets.insert(ets_tablename(client, service), {:credentials, new_credentials})
     {:reply, :ok, {client, service, new_credentials}}
   end
 
   def handle_call(:update_credentials, _from, {client, service, credentials}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     {:ok, new_credentials} = identity(service)
     |> Map.put(credentials, :lock, :false)
     :ets.insert(ets_tablename(client, service), {:credentials, new_credentials})
@@ -91,12 +91,12 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Cache do
   end
 
   def handle_call(:stop, _from, state) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     {:stop, :shutdown, :ok, state}
   end
 
   def terminate(:shutdown, {client, service, credentials}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     :ets.delete(ets_tablename(client, service)) # explicilty remove
     :ok
   end
@@ -198,7 +198,7 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Cache do
 
 
   defp get_credentials(client, service, index) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     if ets_tablename(client, service) in :ets.all() do
       [credentials: credentials] = :ets.lookup(ets_tablename(client, service), :credentials)
       if credentials.lock === :true do
@@ -223,7 +223,7 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Cache do
 
 
   defp monitor_expiry(expires) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     interval = (expires - 30) * 1000
     :timer.sleep(interval)
     {:reply, :ok, _credentials} = GenServer.call(self(), :add_lock)
@@ -235,7 +235,7 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Cache do
 
 
   defp create_ets_table(client, service) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     ets_options = [
                    :set, # type
                    :protected, # read - all, write this process only.
diff --git a/lib/ovh/openstack_api/webstorage/request.ex b/lib/ovh/openstack_api/webstorage/request.ex
index 01d9a6f..9af33a4 100644
--- a/lib/ovh/openstack_api/webstorage/request.ex
+++ b/lib/ovh/openstack_api/webstorage/request.ex
@@ -6,7 +6,7 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Request do
   @spec request(client :: atom, query :: ExOvh.Client.query_t, service :: String.t)
                :: {:ok, ExOvh.Client.response_t} | {:error, ExOvh.Client.response_t}
   def request(client, {method, uri, params} = query, %{ webstorage: service } = opts) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
 
     {method, uri, options} = Auth.prepare_request(client, query, service)
     resp = HTTPotion.request(method, uri, options)
diff --git a/lib/ovh/openstack_api/webstorage/supervisor.ex b/lib/ovh/openstack_api/webstorage/supervisor.ex
index d399400..3a08675 100644
--- a/lib/ovh/openstack_api/webstorage/supervisor.ex
+++ b/lib/ovh/openstack_api/webstorage/supervisor.ex
@@ -11,7 +11,7 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Supervisor do
   Starts the OVH Openstack dynamic supervisor.
   """
   def start_link({client, config, opts}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     Supervisor.start_link(__MODULE__, {client, config, opts}, [name: __MODULE__])
   end
 
@@ -21,7 +21,7 @@ defmodule ExOvh.Ovh.OpenstackApi.Webstorage.Supervisor do
   #####################
 
   def init({client, config, opts}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     tree = [
             {Cache, {Cache, :start_link, [{client, config, opts}]}, :transient, 10_000, :worker, []}
            ]
diff --git a/lib/ovh/ovh_api/cache.ex b/lib/ovh/ovh_api/cache.ex
index eafe5a8..4d59de5 100644
--- a/lib/ovh/ovh_api/cache.ex
+++ b/lib/ovh/ovh_api/cache.ex
@@ -9,7 +9,7 @@ defmodule ExOvh.Ovh.OvhApi.Cache do
 
   @doc "Starts a genserver to keep state on the config and time diff"
   def start_link({client, config, opts}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     GenServer.start_link(__MODULE__, {client, config, opts}, [name: gen_server_name(client)])
   end
 
@@ -29,29 +29,29 @@ defmodule ExOvh.Ovh.OvhApi.Cache do
   ###########################
 
   def init({client, config, opts}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     diff = calculate_diff(config)
     {:ok, {config, diff}}
   end
 
   def handle_call(:get_diff, _from, {config, diff}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     {:reply, diff, {config, diff}}
   end
 
   def handle_call(:get_config, _from, {config, diff}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     {:reply, config, {config, diff}}
   end
 
   def handle_cast({:set_diff, new_diff}, {config, diff}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     {:noreply, {config, new_diff}}
   end
 
   def terminate(:shutdown, state) do
-    LoggingUtils.log_mod_func_line(__ENV__, :warn)
-    LoggingUtils.log_return("gen_server #{__MODULE__} shutting down", :warn)
+    Og.context(__ENV__, :warn)
+    Og.log_return("gen_server #{__MODULE__} shutting down", :warn)
     :ok
   end
 
diff --git a/lib/ovh/ovh_api/request.ex b/lib/ovh/ovh_api/request.ex
index 09b3b57..c39a513 100644
--- a/lib/ovh/ovh_api/request.ex
+++ b/lib/ovh/ovh_api/request.ex
@@ -12,11 +12,11 @@ defmodule ExOvh.Ovh.OvhApi.Request do
   @spec request(client :: atom, query :: ExOvh.Client.query_t, opts :: map)
                :: {:ok, ExOvh.Client.response_t} | {:error, ExOvh.Client.response_t}
   def request(client, {method, uri, params} = query, opts) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     config = config(client)
 
     {method, uri, options} = Auth.prepare_request(client, query)
-    |> LoggingUtils.log_return(:debug)
+    |> Og.log_return(:debug)
 
     resp = HTTPotion.request(method, uri, options)
     if resp.status_code >= 100 and resp.status_code < 300 do
diff --git a/lib/ovh/supervisor.ex b/lib/ovh/supervisor.ex
index 89ac21f..06a2a4a 100644
--- a/lib/ovh/supervisor.ex
+++ b/lib/ovh/supervisor.ex
@@ -12,7 +12,7 @@ defmodule ExOvh.Ovh.Supervisor do
   Starts the OVH supervisor.
   """
   def start_link(client, config, opts) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     Supervisor.start_link(__MODULE__, {client, config, opts}, [name: supervisor_name(client)])
   end
 
@@ -22,7 +22,7 @@ defmodule ExOvh.Ovh.Supervisor do
   #####################
 
   def init({client, config, opts}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     tree = [
             {Cache, {Cache, :start_link, [{client, config, opts}]}, :permanent, 10_000, :worker, [Cache]},
             {Webstorage, {Webstorage, :start_link, [{client, config, opts}]}, :permanent, 10_000, :supervisor, [Webstorage]}
diff --git a/lib/query/openstack/swift/query.ex b/lib/query/openstack/swift/query.ex
index c99b7f7..49a6635 100644
--- a/lib/query/openstack/swift/query.ex
+++ b/lib/query/openstack/swift/query.ex
@@ -141,8 +141,8 @@ defmodule ExOvh.Query.Openstack.Swift do
         path = account <> "/" <> container <> "/" <> server_object
         {:put, path, binary_object}
       {:error, posix_error} ->
-        LoggingUtils.log_mod_func_line(__ENV__, :error)
-        LoggingUtils.log_return(posix_error, :error)
+        Og.context(__ENV__, :error)
+        Og.log_return(posix_error, :error)
         raise posix_error
     end
   end
diff --git a/lib/supervisor.ex b/lib/supervisor.ex
index fac3268..c933947 100644
--- a/lib/supervisor.ex
+++ b/lib/supervisor.ex
@@ -26,7 +26,7 @@ defmodule ExOvh.Supervisor do
   which will crash the supervisor.
   """
   def start_link(client, config, opts) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     Supervisor.start_link(__MODULE__, {client, config, opts}, [name: client])
   end
 
@@ -35,7 +35,7 @@ defmodule ExOvh.Supervisor do
   #####################
 
   def init({client, config, opts}) do
-    LoggingUtils.log_mod_func_line(__ENV__, :debug)
+    Og.context(__ENV__, :debug)
     sup_tree =
     case ovh_config(config, client) do
       {:error, :config_not_found} ->
@@ -48,7 +48,7 @@ defmodule ExOvh.Supervisor do
     sup_tree =
     case hubic_config(config, client) do
       {:error, :config_not_found} ->
-        LoggingUtils.log_return("No hubic config found. Hubic supervisor will not be started for client #{client}", :warn)
+        Og.log_return("No hubic config found. Hubic supervisor will not be started for client #{client}", :warn)
         sup_tree
       valid_config -> sup_tree ++
         [{HubicSupervisor,
diff --git a/mix.exs b/mix.exs
index 7caa655..88bfead 100644
--- a/mix.exs
+++ b/mix.exs
@@ -32,7 +32,7 @@ defmodule ExOvh.Mixfile do
       {:calendar, "~> 0.12.4"},
       {:earmark, "~> 0.2.1", only: :dev},
       {:ex_doc,  "~> 0.11", only: :dev},
-      {:loggingutils, github: "stephenmoloney/loggingutils", only: :dev}
+      {:og, "~> 0.0"}
     ]
   end